Files
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

169 lines
6.6 KiB
HTML

<!--
Copyright 2026 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.
-->
{% extends "base.html" %}
{% block extrahead %}
<!-- HTML Meta Tags -->
<title>Agent Development Kit (ADK)</title>
<meta name="description" content="Build powerful multi-agent systems with Agent Development Kit (ADK)">
<!-- Facebook Meta Tags -->
<meta property="og:url" content="https://adk.dev">
<meta property="og:type" content="website">
<meta property="og:title" content="Agent Development Kit (ADK)">
<meta property="og:description" content="Build powerful multi-agent systems with Agent Development Kit (ADK)">
<meta property="og:image" content="https://adk.dev/assets/adk-social-card.png">
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="adk.dev">
<meta property="twitter:url" content="https://adk.dev">
<meta name="twitter:title" content="Agent Development Kit (ADK)">
<meta name="twitter:description" content="Build powerful multi-agent systems with Agent Development Kit (ADK)">
<meta name="twitter:image" content="https://adk.dev/assets/adk-social-card.png">
<!-- Pagefind search UI. hooks/pagefind.py builds the index and guards both
filenames, so a third asset added here needs adding there too. -->
<link rel="stylesheet" href="{{ 'pagefind/pagefind-component-ui.css' | url }}">
<script type="module" src="{{ 'pagefind/pagefind-component-ui.js' | url }}"></script>
<!-- `| url` covers only the assets above. document.currentScript is null in a
module script, so the bundle always fetches its index from the origin
root: correct at a root domain, wrong under a subpath. -->
<!-- Raise termSimilarity so "LlmAgent" beats pages that merely say "agent"
often. Set on pagefindOptions, which is read lazily; configureInstance()
is ignored once the components create the instance on connect. -->
<script type="module">
window.PagefindComponents
.getInstanceManager()
.getInstance("default")
.pagefindOptions.ranking = { termSimilarity: 2.0 };
</script>
<!-- Mirror Material's data-md-color-scheme onto data-pf-theme, the only
thing that switches Pagefind's dark palette. -->
<script>
(function () {
var sync = function () {
var root = document.documentElement;
if (document.body.getAttribute("data-md-color-scheme") === "slate") {
root.setAttribute("data-pf-theme", "dark");
} else {
root.removeAttribute("data-pf-theme");
}
};
document.addEventListener("DOMContentLoaded", function () {
sync();
new MutationObserver(sync).observe(document.body, {
attributes: true,
attributeFilter: ["data-md-color-scheme"],
});
});
})();
</script>
<!-- Upstream bug: reset-on-close clears the results but never the input, so
the next keystroke appends to the old query. Writing through the native
setter keeps the component in step. Delete this once Pagefind fixes it. -->
<script>
(function () {
document.addEventListener("DOMContentLoaded", function () {
var modal = document.querySelector("pagefind-modal");
// Bind once: the modal outlives instant navigation.
if (!modal || modal.dataset.adkPfClearOnClose) return;
modal.dataset.adkPfClearOnClose = "1";
modal.addEventListener(
"close",
function () {
var input =
modal.querySelector("input") ||
(modal.shadowRoot && modal.shadowRoot.querySelector("input"));
if (!input || !input.value) return;
Object.getOwnPropertyDescriptor(
HTMLInputElement.prototype,
"value",
).set.call(input, "");
input.dispatchEvent(
new Event("input", { bubbles: true, composed: true }),
);
},
true, // `close` does not bubble, but capture still reaches it.
);
});
})();
</script>
<!-- Result links are light DOM, so navigation.instant swaps the page without
unloading the header and the modal stays open. document$ emits after every
swap; close() no-ops when the modal is already closed. -->
<script>
(function () {
document.addEventListener("DOMContentLoaded", function () {
if (!window.document$ || window.__adkPagefindCloseOnNav) return;
window.__adkPagefindCloseOnNav = true;
window.document$.subscribe(function () {
var modal = document.querySelector("pagefind-modal");
if (modal && typeof modal.close === "function") modal.close();
});
});
})();
</script>
<!-- Restore the `/` and `s` shortcuts lost with Material's search plugin;
Pagefind's trigger parses one binding only, already spent on mod+k.
Ignore them with a modifier held, while typing, or while already open. -->
<script>
(function () {
if (window.__adkPagefindSearchKeys) return;
window.__adkPagefindSearchKeys = true;
document.addEventListener("keydown", function (event) {
if (event.key !== "/" && event.key !== "s") return;
if (event.ctrlKey || event.metaKey || event.altKey) return;
var target = event.target;
if (target instanceof Element) {
if (target.isContentEditable) return;
if (target.closest("input, textarea, select")) return;
}
var modal = document.querySelector("pagefind-modal");
if (!modal || typeof modal.open !== "function") return;
var dialog = modal.querySelector("dialog");
if (dialog && dialog.open) return;
event.preventDefault();
modal.open();
});
})();
</script>
{% endblock %}
<!-- top of page announcement banner here: -->
<!--
<span class="announce-item">
<strong>Headline!</strong> descriptive text
<a href="get-started/" target="_blank" rel="noopener">
Link text
</a>
</span>
-->
{% block announce %}
<span class="announce-item">
<a href="/2.0/">
ADK Go 2.0 GA
</a>
is LIVE with graph workflows and collaborative agents! <a href="/get-started/go/">Get started.</a>
</span>
{% endblock %}