From 325acbd194c9d35f14b89bcd7d3a3faad484450c Mon Sep 17 00:00:00 2001 From: Sped0n Date: Fri, 3 Nov 2023 10:11:28 +0800 Subject: [PATCH] feat(sitemap.xml): add sitemap.xml layout file to generate a sitemap for the website The sitemap.xml layout file is added to the project. This layout file generates a sitemap for the website using the data from the pages. The sitemap includes URLs for all pages except those in the "gallery" section. Each URL includes the location, last modified date (if available), change frequency (if available), and priority (if available). If a page is translated, alternate links are included for each translation. --- layouts/sitemap.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 layouts/sitemap.xml diff --git a/layouts/sitemap.xml b/layouts/sitemap.xml new file mode 100644 index 0000000..f931c44 --- /dev/null +++ b/layouts/sitemap.xml @@ -0,0 +1,47 @@ + + {{- range (where .Data.Pages "Section" "!=" "gallery") -}} + + + {{- .Permalink -}} + + {{- if not .Lastmod.IsZero -}} + + {{- .Lastmod.Format "2006-01-02T15:04:05-07:00" -}} + + {{- end -}} + {{- with .Sitemap.ChangeFreq -}} + + {{- . -}} + + {{- end -}} + + {{- if ge .Sitemap.Priority 0.0 -}} + {{- $weeks := div (sub now.Unix .Lastmod.Unix) 604800 -}} + {{- $priority := sub 1 (div $weeks 10.0 ) -}} + {{- if ge .Sitemap.Priority $priority -}} + {{ .Sitemap.Priority }} + {{- else -}} + {{ $priority }} + {{- end -}} + {{- end -}} + + {{- if .IsTranslated -}} + {{- range .Translations -}} + + {{- end -}} + + {{- end -}} + + {{- end -}} +