Merge pull request #4 from jbowdre/preview

RSS improvements
This commit is contained in:
John Bowdre 2024-01-15 14:07:05 -06:00 committed by GitHub
commit 841767dd66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Quick script to run local builds
source .env
hugo --minify --environment local -D
hugo --environment local -D
npx torchlight
python3 -m http.server --directory public 1313

View file

@ -60,3 +60,6 @@ enableInlineShortcodes = true
tag = "tags"
series = "series"
[minify]
disableXML = true
minifyOutput = true

View file

@ -10,9 +10,10 @@
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<!-- {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} -->
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
@ -40,7 +41,9 @@
{{ range (.GetTerms "tags") }}
<category>{{ .LinkTitle }}</category>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | plainify }}</description>
{{- $content := replaceRE "a href=\"(#.*?)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") .Content -}}
{{- $content = replaceRE "img src=\"(.*?)\"" (printf "%s%s%s" "img src=\"" .Permalink "$1\"") $content -}}
<description>{{ $content | html }}</description>
</item>
{{ end }}
</channel>

View file

@ -6,14 +6,14 @@
[context.production]
command = """
hugo --minify
hugo
npm i @torchlight-api/torchlight-cli
npx torchlight
"""
[context.preview]
command = """
hugo --minify --environment preview
hugo --environment preview
npm i @torchlight-api/torchlight-cli
npx torchlight
"""
@ -24,7 +24,7 @@
[context.drafts]
command = """
hugo --minify --environment drafts -D
hugo --environment drafts -D
npm i @torchlight-api/torchlight-cli
npx torchlight
"""