refactor(layouts): simplify alternative output format link rendering

- Use AlternativeOutputFormats to render all links including manifest
- Add rel field to manifest output format config
- Skip manifest link when PWA is disabled
- Remove hardcoded JSON feed link in favor of AlternativeOutputFormats
- Comment out unused mediaTypes section
This commit is contained in:
Cell
2026-06-25 12:51:30 +08:00
parent a5f362f5ff
commit e30b9db23b
3 changed files with 10 additions and 13 deletions
+4 -2
View File
@@ -310,9 +310,10 @@ privacyEnhanced = true
# See: https://gohugo.io/configuration/media-types/
# -------------------------------------------------------------------------------------
[mediaTypes]
# [mediaTypes]
# [mediaTypes."application/feed+json"]
# suffixes = ["json"]
# suffixes = [ "json" ]
# -------------------------------------------------------------------------------------
# Output Format Configuration
@@ -380,6 +381,7 @@ permalinkable = true
[outputFormats.manifest]
baseName = "site"
mediaType = "application/manifest+json"
rel = "manifest"
isPlainText = true
isHTML = false
+5 -10
View File
@@ -85,9 +85,6 @@
{{- with .Site.Params.app.mask_color -}}
<link rel="mask-icon" href="{{ $relURL }}safari-pinned-tab.svg" color="{{ . }}">
{{- end -}}
{{- with .OutputFormats.Get "manifest" -}}
{{- if eq $.Site.Params.app.pwa true -}}<link rel="manifest" href="{{ .RelPermalink }}">{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Canonical and pagination links */ -}}
@@ -99,14 +96,12 @@
<link rel="next" type="text/html" href="{{ .Permalink }}" title="{{ .Title }}" />
{{- end -}}
{{- /* Alternative output formats (Atom, RSS, etc.) */ -}}
{{- /* Alternative output formats (Atom, RSS, manifest etc.) */ -}}
{{- range .AlternativeOutputFormats -}}
{{- printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink $title | safeHTML -}}
{{- end -}}
{{- /* JSON Feed support */ -}}
{{- with .OutputFormats.Get "jsonfeed" -}}
<link rel="alternate" type="application/feed+json" href="{{ .Permalink }}" title="{{ $title }}" />
{{- if (eq .Name "manifest") | and (not $.Site.Params.app.pwa) -}}
{{- continue -}}
{{- end -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
{{- end -}}
{{- /* CSS: base + page-specific */ -}}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v1.0.0-mqorjc8q" -}}
{{- hugo.Store.Set "version" "v1.0.0-mqt0ysyp" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}