From 68b6089139c75363e45711678785bf77fe7d3fa6 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger <285675+cscheid@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:05:20 -0500 Subject: [PATCH] Add `weight` attribute to promote Guide in algolia search (#1541) * new custom attribute for algolia search * Use test index temporarily * Back to `prod` index --------- Co-authored-by: Charlotte Wickham (cherry picked from commit 9dd0c5f1904c20a1959dbbb053898ea902da58b2) --- _quarto.yml | 2 ++ tools/algolia-add-custom-attribute.ts | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 tools/algolia-add-custom-attribute.ts diff --git a/_quarto.yml b/_quarto.yml index b633d8cb91..4276d29e9b 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -1,6 +1,8 @@ project: type: website output-dir: _site + post-render: + - tools/algolia-add-custom-attribute.ts resources: - "/docs/download/_download.json" - "/docs/download/_prerelease.json" diff --git a/tools/algolia-add-custom-attribute.ts b/tools/algolia-add-custom-attribute.ts new file mode 100644 index 0000000000..d516338bb9 --- /dev/null +++ b/tools/algolia-add-custom-attribute.ts @@ -0,0 +1,7 @@ +const j = JSON.parse(Deno.readTextFileSync("_site/search.json")); +j.forEach((entry) => { + const crumb = entry.crumbs || []; + entry.weight = crumb[0] === "Guide" ? 1 : 0; +}) +Deno.writeTextFileSync("_site/search.json", JSON.stringify(j, null, 2)); + \ No newline at end of file