Use custom output format for search index

master
Will Faught 1 year ago
parent 19a794b82f
commit 99cce27a59

@ -428,7 +428,7 @@ Example configuration in `yoursite/hugo.toml`:
```toml ```toml
[outputs] [outputs]
home = ["html", "json", "rss"] home = ["atom", "html", "paige-search", "rss"]
``` ```
Example configuration in `yoursite/content/search.md`: Example configuration in `yoursite/content/search.md`:

@ -85,7 +85,7 @@ startlevel = 2
path = "github.com/willfaught/paige" path = "github.com/willfaught/paige"
[outputs] [outputs]
home = ["atom", "html", "json", "rss"] home = ["atom", "html", "paige-search", "rss"]
section = ["atom", "html", "rss"] section = ["atom", "html", "rss"]
taxonomy = ["atom", "html", "rss"] taxonomy = ["atom", "html", "rss"]
term = ["atom", "html", "rss"] term = ["atom", "html", "rss"]

@ -98,3 +98,9 @@ basename = "rss"
isplaintext = true isplaintext = true
mediatype = "application/rss+xml" mediatype = "application/rss+xml"
name = "rss" name = "rss"
[outputformats.paige-search]
basename = "paige-search"
isplaintext = true
mediatype = "application/json"
notalternative = true

@ -64,9 +64,9 @@ if (paigeQueryElement !== null) {
function paigeSearch(queryText) { function paigeSearch(queryText) {
paigeShow(paigeSearchingElement); paigeShow(paigeSearchingElement);
fetch("{{ relLangURL `index.json` | safeJS }}").then(function (response) { fetch("{{ relLangURL `paige-search.json` | safeJS }}").then(function (response) {
if (response.status !== 200) { 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); paigeHide(paigeSearchingElement);
paigeShow(paigeErrorElement); paigeShow(paigeErrorElement);
return; return;
@ -116,7 +116,7 @@ function paigeSearch(queryText) {
paigeShow(paigeNothingElement); paigeShow(paigeNothingElement);
} }
}).catch(function (error) { }).catch(function (error) {
console.log("Cannot search /index.json", error); console.log("Cannot search /paige-search.json", error);
}); });
}); });
} }

Loading…
Cancel
Save