From 291149732c20b40a76ff27c8cc3ba44fb3a617ac Mon Sep 17 00:00:00 2001 From: Orlix <7236111+OrlinVasilev@users.noreply.github.com> Date: Mon, 24 Apr 2023 20:18:32 +0200 Subject: [PATCH] Algolia fix docs search (#6105) * wip:Algolia fix 2 Signed-off-by: OrlinVasilev * wip:Algolia fix 2 Signed-off-by: OrlinVasilev * Algolia fix 2 Signed-off-by: OrlinVasilev * Update site/layouts/partials/head-docs.html Co-authored-by: Tiger Kaovilai Signed-off-by: Orlix <7236111+OrlinVasilev@users.noreply.github.com> --------- Signed-off-by: OrlinVasilev Signed-off-by: Orlix <7236111+OrlinVasilev@users.noreply.github.com> Co-authored-by: Tiger Kaovilai --- site/algolia-crawler.json | 90 ++++++++++++++++++++++++++++ site/layouts/docs/docs.html | 31 +++++----- site/layouts/partials/head-docs.html | 2 + 3 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 site/algolia-crawler.json diff --git a/site/algolia-crawler.json b/site/algolia-crawler.json new file mode 100644 index 000000000..06dc083d7 --- /dev/null +++ b/site/algolia-crawler.json @@ -0,0 +1,90 @@ +new Crawler({ + rateLimit: 8, + maxDepth: 10, + startUrls: ["https://velero.io/docs", "https://velero.io/"], + renderJavaScript: false, + sitemaps: ["https://velero.io/sitemap.xml"], + ignoreCanonicalTo: false, + discoveryPatterns: ["https://velero.io/**"], + schedule: "at 6:39 PM on Friday", + actions: [ + { + indexName: "velero_new", + pathsToMatch: ["https://velero.io/docs**/**"], + recordExtractor: ({ helpers }) => { + return helpers.docsearch({ + recordProps: { + lvl1: ["header h1", "article h1", "main h1", "h1", "head > title"], + content: ["article p, article li", "main p, main li", "p, li"], + lvl0: { + defaultValue: "Documentation", + }, + lvl2: ["article h2", "main h2", "h2"], + lvl3: ["article h3", "main h3", "h3"], + lvl4: ["article h4", "main h4", "h4"], + lvl5: ["article h5", "main h5", "h5"], + lvl6: ["article h6", "main h6", "h6"], + version: "#dropdownMenuButton", + }, + aggregateContent: true, + recordVersion: "v3", + }); + }, + }, + ], + initialIndexSettings: { + velero_new: { + attributesForFaceting: ["type", "lang", "version"], + attributesToRetrieve: [ + "hierarchy", + "content", + "anchor", + "url", + "url_without_anchor", + "type", + "version", + ], + attributesToHighlight: ["hierarchy", "content"], + attributesToSnippet: ["content:10"], + camelCaseAttributes: ["hierarchy", "content"], + searchableAttributes: [ + "unordered(hierarchy.lvl0)", + "unordered(hierarchy.lvl1)", + "unordered(hierarchy.lvl2)", + "unordered(hierarchy.lvl3)", + "unordered(hierarchy.lvl4)", + "unordered(hierarchy.lvl5)", + "unordered(hierarchy.lvl6)", + "content", + ], + distinct: true, + attributeForDistinct: "url", + customRanking: [ + "desc(weight.pageRank)", + "desc(weight.level)", + "asc(weight.position)", + ], + ranking: [ + "words", + "filters", + "typo", + "attribute", + "proximity", + "exact", + "custom", + ], + highlightPreTag: '', + highlightPostTag: "", + minWordSizefor1Typo: 3, + minWordSizefor2Typos: 7, + allowTyposOnNumericTokens: false, + minProximity: 1, + ignorePlurals: true, + advancedSyntax: true, + attributeCriteriaComputedByMinProximity: true, + removeWordsIfNoResults: "allOptional", + }, + }, + appId: "9ASKQJ1HR3", + apiKey: "6392a5916af73b73df2406d3aef5ca45", +}); \ No newline at end of file diff --git a/site/layouts/docs/docs.html b/site/layouts/docs/docs.html index 938ce660d..6d2a3f57f 100644 --- a/site/layouts/docs/docs.html +++ b/site/layouts/docs/docs.html @@ -27,14 +27,16 @@
{{ .Render "versions" }}
-
- - - -
+
+ +
{{ .Render "nav" }}
@@ -56,13 +58,14 @@ {{ .Render "footer" }}
- + diff --git a/site/layouts/partials/head-docs.html b/site/layouts/partials/head-docs.html index c92837b2f..5ebae8c24 100644 --- a/site/layouts/partials/head-docs.html +++ b/site/layouts/partials/head-docs.html @@ -8,4 +8,6 @@ {{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }} {{/* TODO {% seo %}*/}} + +