aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanilo G. Baio <dbaio@FreeBSD.org>2021-07-15 11:48:00 +0000
committerDanilo G. Baio <dbaio@FreeBSD.org>2021-07-15 22:09:25 +0000
commite06f3556beb198cbaf10136ad54af94e19cebf10 (patch)
tree6020100f9271ad21ae3fe21447a423d6d33a76e6
parentadb40cf1421429466766fdab91d0eb4112950a08 (diff)
website/press: Adjust all links
- Fix RSS/Feed links They were without the anchor part, causing 404 requests: https://www.freebsd.org/press/2021-03:0 The correct is: https://www.freebsd.org/press/#2021-03:0 - Make links unique When investigating the above issue, we could note that the links were not unique. Every time a new press item is added, the entire chain of links is changed. We add the old behavior with this change, which counts press items for each month and generates the unique link based on the month and in the month counter. This change also needs to be added to the News and Events items. Reviewed by: carlavilla Differential Revision: https://reviews.freebsd.org/D31190
-rw-r--r--website/themes/beastie/layouts/partials/press.html13
-rw-r--r--website/themes/beastie/layouts/press/list.html13
-rw-r--r--website/themes/beastie/layouts/press/press.rss.xml27
-rw-r--r--website/themes/beastie/layouts/press/single.html13
4 files changed, 49 insertions, 17 deletions
diff --git a/website/themes/beastie/layouts/partials/press.html b/website/themes/beastie/layouts/partials/press.html
index ca0e3c1d16..6bca5eece6 100644
--- a/website/themes/beastie/layouts/partials/press.html
+++ b/website/themes/beastie/layouts/partials/press.html
@@ -16,14 +16,23 @@
{{ with $pressData.press }}
{{ $pressCounter := 0 }}
+ {{ $pressMonthCounter := 1 }}
+ {{ $pressMonthPrev := false }}
{{ range (sort .press "date" "desc") }}
{{ if lt $pressCounter 5 }}
+ {{ $pressMonthCur := dateFormat "2006-01" .date }}
+ {{ if eq $pressMonthCur $pressMonthPrev }}
+ {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+ {{ else }}
+ {{ $pressMonthCounter = 1 }}
+ {{ end }}
<p>
<span class="txtdate">{{ dateFormat "2006-01" .date }}</span>
<br />
- <a href="{{ if $translatedPressEnabled }}{{ .Site.BaseURL | relLangURL }}{{ else }}{{ $.Site.BaseURL }}{{ end }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}">{{ .name }}</a>
+ <a href="{{ if $translatedPressEnabled }}{{ .Site.BaseURL | relLangURL }}{{ else }}{{ $.Site.BaseURL }}{{ end }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}">{{ .name }}</a>
</p>
+ {{ $pressCounter = add $pressCounter 1 }}
+ {{ $pressMonthPrev = $pressMonthCur }}
{{ end }}
- {{ $pressCounter = add $pressCounter 1 }}
{{ end }}
{{ end }}
diff --git a/website/themes/beastie/layouts/press/list.html b/website/themes/beastie/layouts/press/list.html
index f34ae7e986..332c4de940 100644
--- a/website/themes/beastie/layouts/press/list.html
+++ b/website/themes/beastie/layouts/press/list.html
@@ -39,7 +39,8 @@
<!-- Remove duplicates -->
{{ $yearsMonths = $yearsMonths | uniq }}
- {{ $pressCounter := 0 }}
+ {{ $pressMonthCounter := 1 }}
+ {{ $pressMonthPrev := false }}
{{ range $year := seq now.Year 2010 }}
{{ range $month := seq 12 1 }}
{{ $yearMonth := (printf "%d-%d" $year $month) }}
@@ -50,9 +51,15 @@
{{ with $pressData.press }}
{{ range (sort .press "date" "desc") }}
{{ if eq (dateFormat "2006-1" .date) $yearMonth }}
+ {{ $pressMonthCur := dateFormat "2006-01" .date }}
+ {{ if eq $pressMonthCur $pressMonthPrev }}
+ {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+ {{ else }}
+ {{ $pressMonthCounter = 1 }}
+ {{ end }}
<li>
<p>
- <a id="{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}"></a>
+ <a id="{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}"></a>
<a href="{{ .url }}">
<strong>{{ .name }}</strong>
</a>
@@ -62,7 +69,7 @@
{{ .description | safeHTML}}
</p>
</li>
- {{ $pressCounter = add $pressCounter 1 }}
+ {{ $pressMonthPrev = $pressMonthCur }}
{{ end }}
{{ end }}
{{ end }}
diff --git a/website/themes/beastie/layouts/press/press.rss.xml b/website/themes/beastie/layouts/press/press.rss.xml
index 98f0348c85..660c49652d 100644
--- a/website/themes/beastie/layouts/press/press.rss.xml
+++ b/website/themes/beastie/layouts/press/press.rss.xml
@@ -12,28 +12,37 @@
<link>https://www.FreeBSD.org/press/</link>
</image>
<atom:link href="https://www.FreeBSD.org/press/feed.xml" rel="self" type="application/rss+xml"/>
+ {{ $pressMonthPrev := false }}
{{ $data := index .Site.Data "en" }}
{{ $pressData := $data.press }}
{{ with $pressData.press }}
{{ $pressCounter := 0 }}
- {{ range (sort .press "date" "desc") }}
- {{ if lt $pressCounter 10 }}
+ {{ $pressMonthCounter := 1 }}
+ {{ range (sort .press "date" "desc") }}
+ {{ if lt $pressCounter 10 }}
+ {{ $pressMonthCur := dateFormat "2006-01" .date }}
+ {{ if eq $pressMonthCur $pressMonthPrev }}
+ {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+ {{ else }}
+ {{ $pressMonthCounter = 1 }}
+ {{ end }}
<item>
- {{ if .name }}
+ {{ if .name }}
<title>
{{ .name }}
</title>
- {{ end }}
- {{ if .description }}
+ {{ end }}
+ {{ if .description }}
<description>
{{ .description }}
</description>
- {{ end }}
- <link>{{ absLangURL ($.Site.BaseURL) }}press/{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}</link>
- <guid>{{ absLangURL ($.Site.BaseURL) }}press/{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}</guid>
+ {{ end }}
+ <link>{{ absLangURL ($.Site.BaseURL) }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}</link>
+ <guid>{{ absLangURL ($.Site.BaseURL) }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}</guid>
<pubDate>{{ dateFormat "2006-01-02" .date }}</pubDate>
</item>
- {{ end }}
+ {{ $pressMonthPrev = $pressMonthCur }}
+ {{ end }}
{{ $pressCounter = add $pressCounter 1 }}
{{ end }}
{{ end }}
diff --git a/website/themes/beastie/layouts/press/single.html b/website/themes/beastie/layouts/press/single.html
index f34ae7e986..332c4de940 100644
--- a/website/themes/beastie/layouts/press/single.html
+++ b/website/themes/beastie/layouts/press/single.html
@@ -39,7 +39,8 @@
<!-- Remove duplicates -->
{{ $yearsMonths = $yearsMonths | uniq }}
- {{ $pressCounter := 0 }}
+ {{ $pressMonthCounter := 1 }}
+ {{ $pressMonthPrev := false }}
{{ range $year := seq now.Year 2010 }}
{{ range $month := seq 12 1 }}
{{ $yearMonth := (printf "%d-%d" $year $month) }}
@@ -50,9 +51,15 @@
{{ with $pressData.press }}
{{ range (sort .press "date" "desc") }}
{{ if eq (dateFormat "2006-1" .date) $yearMonth }}
+ {{ $pressMonthCur := dateFormat "2006-01" .date }}
+ {{ if eq $pressMonthCur $pressMonthPrev }}
+ {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+ {{ else }}
+ {{ $pressMonthCounter = 1 }}
+ {{ end }}
<li>
<p>
- <a id="{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}"></a>
+ <a id="{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}"></a>
<a href="{{ .url }}">
<strong>{{ .name }}</strong>
</a>
@@ -62,7 +69,7 @@
{{ .description | safeHTML}}
</p>
</li>
- {{ $pressCounter = add $pressCounter 1 }}
+ {{ $pressMonthPrev = $pressMonthCur }}
{{ end }}
{{ end }}
{{ end }}