Files
google__adk-docs/overrides/partials/header.html
Haran Rajkumar 64a9449cf2 Replace site search with Pagefind (#2096)
* feat(search): replace the built-in search with Pagefind

Material's search ranked identifier queries badly, split one page across
a row per heading, and showed only the first handful of matches. Pagefind
indexes at build time, groups sub-results under their page, and pages
through the whole result set.

hooks/pagefind.py marks each page's content <article> with
data-pagefind-body and runs the indexer over the built site. It fails the
build on six conditions: the anchor missing, nothing marked, marked and
indexed counts disagreeing, an exclude selector matching no page, a UI
asset not emitted, and the ranking API gone from the bundle.
MKDOCS_PAGEFIND_SKIP=1 skips indexing for a faster `mkdocs serve`, warns
so that --strict fails pull requests, and is refused under gh-deploy,
which publishes without --strict.

The header hosts Pagefind's own modal and trigger components, so there is
little UI to own. overrides/main.html raises termSimilarity so "LlmAgent"
beats pages that merely say "agent" often, mirrors Material's colour
scheme onto data-pf-theme, clears the search input on close around an
upstream bug, and restores the / and s shortcuts that left with the old
plugin. The lunr-specific CSS is gone.

* Update header.html

* Update custom.css

* Update custom.css

---------

Co-authored-by: Joe Fernandez <931947+joefernandez@users.noreply.github.com>
2026-08-21 21:28:11 +00:00

112 lines
3.4 KiB
HTML

<!--
Copyright 2025 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Determine classes -->
{% set class = "md-header" %}
{% if "navigation.tabs.sticky" in features %}
{% set class = class ~ " md-header--shadow md-header--lifted" %}
{% elif "navigation.tabs" not in features %}
{% set class = class ~ " md-header--shadow" %}
{% endif %}
<!-- Header -->
<header class="{{ class }}" data-md-component="header">
<nav
class="md-header__inner md-grid"
aria-label="{{ lang.t('header') }}"
>
<!-- Link to home -->
<a
href="{{ config.extra.homepage | d(nav.homepage.url, true) | url }}"
title="{{ config.site_name | e }}"
class="md-header__button md-logo"
aria-label="{{ config.site_name }}"
data-md-component="logo"
>
{% include "partials/logo.html" %}
</a>
<!-- Button to open drawer -->
<label class="md-header__button md-icon" for="__drawer">
{% set icon = config.theme.icon.menu or "material/menu" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</label>
<!-- Header title -->
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
<a
href="{{ config.extra.homepage | d(nav.homepage.url, true) | url }}"
title="{{ config.site_name | e }}"
aria-label="{{ config.site_name }}"
data-md-component="logo"
>
{{ config.site_name }}
</a>
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
{% if page.meta and page.meta.title %}
{{ page.meta.title }}
{% else %}
{{ page.title }}
{% endif %}
</a>
</span>
</div>
</div>
</div>
<!-- Language SDK repository links -->
<div class="lang-header-repos">
{% include "partials/source.html" %}
</div>
<!-- Color palette toggle -->
{% if config.theme.palette %}
{% if not config.theme.palette is mapping %}
{% include "partials/palette.html" %}
{% endif %}
{% endif %}
<!-- User preference: color palette -->
{% if not config.theme.palette is mapping %}
{% include "partials/javascripts/palette.html" %}
{% endif %}
<!-- Site language selector -->
{% if config.extra.alternate %}
{% include "partials/alternate.html" %}
{% endif %}
<!-- Pagefind search. Both live in the header nav, which survives
navigation.instant DOM swaps, so the modal keeps its state. -->
<pagefind-modal-trigger placeholder="Search"></pagefind-modal-trigger>
<pagefind-modal reset-on-close></pagefind-modal>
</nav>
<!-- Navigation tabs (sticky) -->
{% if "navigation.tabs.sticky" in features %}
{% if "navigation.tabs" in features %}
{% include "partials/tabs.html" %}
{% endif %}
{% endif %}
</header>