From 99cce27a599043c01da0ca4d91686c9c72ac9d6b Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 7 Apr 2024 19:03:01 -0700 Subject: [PATCH] Use custom output format for search index --- README.md | 2 +- exampleSite/hugo.toml | 2 +- hugo.toml | 6 ++++++ layouts/_default/{home.json => home.paige-search.json} | 0 layouts/partials/paige/search.html | 6 +++--- 5 files changed, 11 insertions(+), 5 deletions(-) rename layouts/_default/{home.json => home.paige-search.json} (100%) diff --git a/README.md b/README.md index 00481603..dd6fd301 100644 --- a/README.md +++ b/README.md @@ -428,7 +428,7 @@ Example configuration in `yoursite/hugo.toml`: ```toml [outputs] -home = ["html", "json", "rss"] +home = ["atom", "html", "paige-search", "rss"] ``` Example configuration in `yoursite/content/search.md`: diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index e70276f6..c0b2ac26 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -85,7 +85,7 @@ startlevel = 2 path = "github.com/willfaught/paige" [outputs] -home = ["atom", "html", "json", "rss"] +home = ["atom", "html", "paige-search", "rss"] section = ["atom", "html", "rss"] taxonomy = ["atom", "html", "rss"] term = ["atom", "html", "rss"] diff --git a/hugo.toml b/hugo.toml index 338f6f0f..5e40c28e 100644 --- a/hugo.toml +++ b/hugo.toml @@ -98,3 +98,9 @@ basename = "rss" isplaintext = true mediatype = "application/rss+xml" name = "rss" + +[outputformats.paige-search] +basename = "paige-search" +isplaintext = true +mediatype = "application/json" +notalternative = true diff --git a/layouts/_default/home.json b/layouts/_default/home.paige-search.json similarity index 100% rename from layouts/_default/home.json rename to layouts/_default/home.paige-search.json diff --git a/layouts/partials/paige/search.html b/layouts/partials/paige/search.html index 201b89a5..cb90b45b 100644 --- a/layouts/partials/paige/search.html +++ b/layouts/partials/paige/search.html @@ -64,9 +64,9 @@ if (paigeQueryElement !== null) { function paigeSearch(queryText) { paigeShow(paigeSearchingElement); - fetch("{{ relLangURL `index.json` | safeJS }}").then(function (response) { + fetch("{{ relLangURL `paige-search.json` | safeJS }}").then(function (response) { if (response.status !== 200) { - console.log("Cannot load {{ relLangURL `index.json` | safeJS }}", response); + console.log("Cannot load {{ relLangURL `paige-search.json` | safeJS }}", response); paigeHide(paigeSearchingElement); paigeShow(paigeErrorElement); return; @@ -116,7 +116,7 @@ function paigeSearch(queryText) { paigeShow(paigeNothingElement); } }).catch(function (error) { - console.log("Cannot search /index.json", error); + console.log("Cannot search /paige-search.json", error); }); }); }