mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
3ffef8acb0
* 🔍 Refactor: add JSON feed support and refactor output formats build in FixIt Close #475 * 🚚 Feat: migrate index templates to layouts/_default folder and home.[name].html * 📝 Style(ignore): fix typo * 🚚 Chore: migrate index templates to default home templates * 🚚 Chore: migrate section templates to layouts/section folder * ✨ Feat: add JSON feed support for section pages (#475) * 🚧 Feat: add common template for JSON feed (#475) * 🚧 Feat: add JSON feed support for section and term list pages * 🚀 Chore: fix git stage error in update-version script * ⚡ Perf: add front matter hiddenFromFeed for JSON feed (#475) * 🔍 Feat: add tags attribute for JSON feed (#475) * ♻️ Refactor: refactor RSS feed templates Close #488 * 🚧 WIP: rename json-feed.html to json.html * 🚧 Feat: revert single.md * ⚡ Perf: enhance JSON feed 1.1 compatibility * ♻️ Refactor: refactor post author map getting * ✨ WIP: add featured image support in feed * 📝 Docs: update README and screenshot * 🔧 Chore: update changelog template * 🚧 WIP: add feed scoped config for section and list * 🔥 Feat: migrate JSON feed to hugo-fixit/hugo-json-feed Close hugo-fixit/hugo-json-feed#1 * 🚚 Feat: remove front matter hiddenFromRss and rssFullText, add front matter hiddenFromFeed
47 lines
2.2 KiB
JSON
47 lines
2.2 KiB
JSON
{{- if .Site.Params.search.enable -}}
|
|
{{- $index := slice -}}
|
|
{{- $pages := where .Site.RegularPages "Params.password" "eq" nil -}}
|
|
{{- if .Site.Params.page.hiddenFromSearch -}}
|
|
{{- $pages = where $pages "Params.hiddenfromsearch" false -}}
|
|
{{- else -}}
|
|
{{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}}
|
|
{{- end -}}
|
|
{{- range $pages -}}
|
|
{{- $uri := .RelPermalink -}}
|
|
{{- if $.Site.Params.search.absoluteURL -}}
|
|
{{- $uri = .Permalink -}}
|
|
{{- end -}}
|
|
{{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}}
|
|
{{- $meta = $.Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format | dict "date" | merge $meta -}}
|
|
{{- with .Description -}}
|
|
{{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}}
|
|
{{- end -}}
|
|
{{- $params := .Params | merge $.Site.Params.page -}}
|
|
{{/* Extended Markdown syntax */}}
|
|
{{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}}
|
|
{{/* Remove line number for code */}}
|
|
{{- $content = $content | replaceRE `<span class="lnt?"> *\d*\n?</span>` "" -}}
|
|
{{- range $i, $contenti := split $content "<h2 id=" -}}
|
|
{{- if gt $i 0 -}}
|
|
{{- $contenti = printf "<h2 id=%v" $contenti -}}
|
|
{{- end -}}
|
|
{{- range $j, $contentj := split $contenti "<h3 id=" -}}
|
|
{{- if gt $j 0 -}}
|
|
{{- $contentj = printf "<h3 id=%v" $contentj -}}
|
|
{{- end -}}
|
|
{{/* Plainify, unescape and remove (\n, \t) */}}
|
|
{{- $contentj = $contentj | plainify | htmlUnescape | replaceRE `[\n\t ]+` " " -}}
|
|
{{- if gt $.Site.Params.search.contentLength 0 -}}
|
|
{{- $contentj = substr $contentj 0 $.Site.Params.search.contentLength -}}
|
|
{{- end -}}
|
|
{{- if $contentj | and (ne $contentj " ") -}}
|
|
{{- $one := printf "%v:%v:%v" $uri $i $j | dict "content" $contentj "objectID" | merge $meta -}}
|
|
{{- $index = $index | append $one -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $index | jsonify | safeJS -}}
|
|
{{- end -}}
|