From 2242e0c3c74a95afb5f11f366977ce1d9a0b16ba Mon Sep 17 00:00:00 2001 From: Andrea Carratta <46504271+devandreacarratta@users.noreply.github.com> Date: Fri, 29 May 2020 05:09:06 +0200 Subject: [PATCH] feat(sitemap): improve priority (#392) Co-authored-by: Dillon --- layouts/sitemap.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/layouts/sitemap.xml b/layouts/sitemap.xml index d13d9280..f931c442 100644 --- a/layouts/sitemap.xml +++ b/layouts/sitemap.xml @@ -17,11 +17,17 @@ {{- . -}} {{- end -}} + {{- if ge .Sitemap.Priority 0.0 -}} - - {{- .Sitemap.Priority -}} - + {{- $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 -}}