Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ extra_javascript:
# Reserve image space and defer below-the-fold screenshots without a frontend build step.
hooks:
- "theme/hooks/image_metadata.py"
# Rank Self-hosted pages (docs/chart/) below Cloud pages in search results.
- "theme/hooks/search_boost.py"

# Extra variables
# https://github.com/rosscdh/mkdocs-markdownextradata-plugin
Expand Down
22 changes: 22 additions & 0 deletions theme/hooks/search_boost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Rank Codacy Self-hosted pages below Cloud pages in site search.

Most readers are on Codacy Cloud, but Self-hosted pages often share a Cloud
page's title (for example, "Slack integration"), so they can outrank the page
the reader needs. Material's search plugin reads a per-page boost from
`search.boost` in the page metadata; this sets it for every page under
`chart/` (the Self-hosted section) instead of repeating it in each page's
front matter. A page that sets its own `search.boost` keeps it.
"""

from __future__ import annotations

SELF_HOSTED_PREFIX = "chart/"
SELF_HOSTED_BOOST = 0.5


def on_page_markdown(markdown, page, **kwargs):
if page.file.src_uri.startswith(SELF_HOSTED_PREFIX):
search = page.meta.get("search") or {}
search.setdefault("boost", SELF_HOSTED_BOOST)
page.meta["search"] = search
return markdown
2 changes: 2 additions & 0 deletions theme/stylesheets/header.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading