Skip to content

Commit df1e688

Browse files
Issue-482: Fix for archive page displayed in latest post section (#483)
1 parent 95f58b0 commit df1e688

File tree

9 files changed

+65
-14
lines changed

9 files changed

+65
-14
lines changed

exampleSite/config.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ disqusShortname = ""
138138
# social media profile urls for the footer links
139139
showSocialMedia = true
140140

141-
# show an archive link in the footer
142-
showArchive = false
143-
144-
# archive grouping: "2006" by year, "2006-01" by month
145-
archiveDateGrouping = "2006-01"
146-
147141
# define your links with FontAwesome 5 (only free icons are supported)
148142
# all icons https://fontawesome.com/icons?d=gallery&m=free
149143
# brand icons https://fontawesome.com/icons?d=gallery&s=brands&m=free
@@ -152,6 +146,12 @@ disqusShortname = ""
152146
{ link = "https://github.com/Lednerb", icon = "fab fa-github" },
153147
]
154148

149+
# show an archive link in the footer
150+
showArchive = false
151+
152+
# archive grouping: "2006" by year, "2006-01" by month
153+
archiveDateGrouping = "2006-01"
154+
155155
# credits line configuration
156156
copyrightBy = "by Lednerb"
157157
copyrightUseCurrentYear = true # set to true to always display the current year in the copyright

exampleSite/content/archive.de.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Archivseite"
3+
type: archive
4+
excludeFromIndex: true
5+
---

exampleSite/content/archive.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Archive page"
2+
title: "Archive Page"
33
type: archive
44
excludeFromIndex: true
55
---

layouts/archive/single.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{{ define "main" }}
22
<div class="content">
33
<div class="article-wrapper u-cf single">
4-
<a class="bubble" href="{{ "/archive/" | relLangURL}}">
4+
{{ with .Site.GetPage "/archive" }}
5+
<a class="bubble" href="{{ .Permalink }}">
56
<i class="fa fa-fw fa-archive"></i>
67
</a>
8+
{{ end }}
79

810
<article class="article">
911
<div class="content">
10-
<h1 class="article-title">{{ i18n "archive" }}</h1>
12+
{{ with .Site.GetPage "/archive" }}
13+
<h1 class="article-title">{{ .Title }}</h1>
14+
{{ end }}
1115
<div class="meta"></div>
1216
<div class="archive-list">
1317
{{ range (where .Site.RegularPages "Type" "not in" (slice "page" "archive" "status" ) ).GroupByPublishDate (.Site.Params.archiveDateGrouping | default "2006-01") }}

layouts/partials/footer.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="recent-posts">
77
<strong>{{ i18n "latestPosts" }}</strong>
88
<ul>
9-
{{ $dontRender := (slice "page" "quote" "link" "status") }}
9+
{{ $dontRender := (slice "page" "quote" "link" "status" "archive") }}
1010
{{ range (first (.Site.Params.amountLatestPostsInFooter | default 7) (where (where .Site.Pages.ByPublishDate.Reverse ".Kind" "page") ".Type" "not in" $dontRender )) }}
1111
<li>
1212
<a href="{{ .Permalink }}">{{ .Title }}</a>
@@ -19,7 +19,7 @@
1919
{{ if and .Site.Taxonomies.categories (gt ( .Site.Params.amountCategoriesInFooter | default 7 ) 0 ) }}
2020
<div class="categories">
2121
{{ with .Site.GetPage "/categories" }}
22-
<a href="{{ .Permalink }}"><strong>{{ .Title }}</strong></a>
22+
<a href="{{ .Permalink }}"><strong>{{ i18n "categories" }}</strong></a>
2323
{{ end }}
2424

2525
<ul>
@@ -38,7 +38,6 @@
3838
{{ if .Site.Params.showSocialMedia | default true }}
3939
<div class="external-profiles">
4040
<strong>{{ i18n "socialMedia" }}</strong>
41-
4241
{{ range .Site.Params.socialMediaLinks }}
4342
<a href="{{ .link }}" target="_blank" rel="{{ .rel }}"><em class="{{ .icon }}"></em></a>
4443
{{ end }}
@@ -62,7 +61,7 @@
6261
{{ if .Site.Params.showArchive | default true }}
6362
<div class="archive">
6463
{{ with .Site.GetPage "/archive" }}
65-
<a href="{{ .Permalink }}"><strong>{{ .Title }}</strong></a>
64+
<a href="{{ .Permalink }}"><strong>{{ i18n "archive" }}</strong></a>
6665
{{ end }}
6766
</div>
6867
{{ end }}

testing/testing-example-site/config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ disqusShortname = "bilberry-hugo-theme"
119119
{ link = "https://github.com/Lednerb", icon = "fab fa-github" },
120120
]
121121

122+
# show an archive link in the footer
123+
showArchive = true
124+
125+
# archive grouping: "2006" by year, "2006-01" by month
126+
archiveDateGrouping = "2006-01"
127+
122128
# credits line configuration
123129
copyrightBy = "by Lednerb"
124130
copyrightUseCurrentYear = false # set to true to always display the current year in the copyright
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Archivseite"
3+
type: archive
4+
excludeFromIndex: true
5+
---
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "Archive Page"
3+
type: archive
4+
excludeFromIndex: true
5+
---

testing/testing-example-site/test-theme.sh

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ testFolderAndContinue "$TARGET_DIR/de/tags/c++"
8686
testFolderAndContinue "$TARGET_DIR/tags/tästing++"
8787
testFolderAndContinue "$TARGET_DIR/de/tags/tästing++"
8888

89+
testFolderAndContinue "$TARGET_DIR/archive"
90+
testFolderAndContinue "$TARGET_DIR/de/archive"
91+
8992
# article/täst [en]
9093
echo "## Testing article/täst [en]"
9194
testContentAndContinue '<a href="https://example.com/categories/t%C3%A4st&#43;&#43;/">Täst&#43;&#43;</a>' "$TARGET_DIR/article/täst/index.html"
@@ -96,7 +99,7 @@ testContentAndContinue '<a href="https://example.com/de/article/t%C3%A4st/">de</
9699
testContentAndContinue '<a href="https://example.com/article/t%C3%A4st/">Umlauts Täst&#43;&#43;</a>' "$TARGET_DIR/article/täst/index.html"
97100
testContentAndContinue '<p>This is a umlauts-test in Quotes äüöß++</p>' "$TARGET_DIR/quote/index.html"
98101
testContentAndContinue '<a href="https://example.com/categories/t%C3%A4st&#43;&#43;/">Täst&#43;&#43; (2)</a>' "$TARGET_DIR/article/täst/index.html"
99-
102+
testContentAndContinue '<a href="https://example.com/archive/"><strong>Archive</strong></a>' "$TARGET_DIR/article/täst/index.html"
100103
# article/täst [de]
101104
echo "## Testing article/täst [de]"
102105
testContentAndContinue '<a href="https://example.com/de/categories/t%C3%A4st&#43;&#43;/">Täst&#43;&#43;</a>' "$TARGET_DIR/de/article/täst/index.html"
@@ -107,6 +110,7 @@ testContentAndContinue '<a href="https://example.com/article/t%C3%A4st/">en</a>'
107110
testContentAndContinue '<a href="https://example.com/de/article/t%C3%A4st/">de Umlauts Täst&#43;&#43;</a>' "$TARGET_DIR/de/article/täst/index.html"
108111
testContentAndContinue '<p>de This is a umlauts-test in quotes äüöß++</p>' "$TARGET_DIR/de/quote/index.html"
109112
testContentAndContinue '<a href="https://example.com/de/categories/t%C3%A4st&#43;&#43;/">Täst&#43;&#43; (2)</a>' "$TARGET_DIR/de/article/täst/index.html"
113+
testContentAndContinue '<a href="https://example.com/de/archive/"><strong>Archiv</strong></a>' "$TARGET_DIR/de/article/täst/index.html"
110114

111115
# quote/täst-quote [en]
112116
echo "## Testing quote/täst-quote [en]"
@@ -120,6 +124,29 @@ testContentAndContinue '<a href="/de/author/%c3%a4-%c3%9f&#43;">
120124
ä ß&#43;
121125
</a>' "$TARGET_DIR/de/quote/täst-quote/index.html"
122126

127+
# archive [en]
128+
echo "## Testing archive [en]"
129+
testContentAndContinue '<a class="bubble" href="https://example.com/archive/">' "$TARGET_DIR/archive/index.html"
130+
testContentAndContinue '<h1 class="article-title">Archive Page</h1>' "$TARGET_DIR/archive/index.html"
131+
testContentAndContinue '<h4>2020-05</h4>' "$TARGET_DIR/archive/index.html"
132+
testContentAndContinue '<a href="https://example.com/article/long-text/">long text <span>(2020-05-15)</span></a>' "$TARGET_DIR/archive/index.html"
133+
testContentAndContinue '<h4>2020-04</h4>' "$TARGET_DIR/archive/index.html"
134+
testContentAndContinue '<a href="https://example.com/article/long-text-1/">long text 1 <span>(2020-04-15)</span></a>' "$TARGET_DIR/archive/index.html"
135+
testContentAndContinue '<h4>2020-03</h4>' "$TARGET_DIR/archive/index.html"
136+
testContentAndContinue '<a href="https://example.com/article/long-text-manual-readmore/">long text manual readmore <span>(2020-03-15)</span></a>' "$TARGET_DIR/archive/index.html"
137+
testContentAndContinue '<h4>2020-02</h4>' "$TARGET_DIR/archive/index.html"
138+
testContentAndContinue '<a href="https://example.com/article/shorttextwithcode/">long text <span>(2020-02-15)</span></a>' "$TARGET_DIR/archive/index.html"
139+
testContentAndContinue '<h4>2020-01</h4>' "$TARGET_DIR/archive/index.html"
140+
testContentAndContinue '<a href="https://example.com/article/t%C3%A4st/">Umlauts Täst&#43;&#43; <span>(2020-01-15)</span></a>' "$TARGET_DIR/archive/index.html"
141+
testContentAndContinue '<a href="https://example.com/quote/t%C3%A4st-quote/">Quote Umlauts Täst&#43;&#43; <span>(2020-01-14)</span></a>' "$TARGET_DIR/archive/index.html"
142+
143+
# archive [de]
144+
echo "## Testing archive [de]"
145+
testContentAndContinue '<a class="bubble" href="https://example.com/de/archive/">' "$TARGET_DIR/de/archive/index.html"
146+
testContentAndContinue '<h1 class="article-title">Archivseite</h1>' "$TARGET_DIR/de/archive/index.html"
147+
testContentAndContinue '<h4>2020-01</h4>' "$TARGET_DIR/de/archive/index.html"
148+
testContentAndContinue '<a href="https://example.com/de/article/t%C3%A4st/">de Umlauts Täst&#43;&#43; <span>(2020-01-15)</span></a>' "$TARGET_DIR/de/archive/index.html"
149+
testContentAndContinue '<a href="https://example.com/de/quote/t%C3%A4st-quote/">de Quote Umlauts Täst&#43;&#43; <span>(2020-01-14)</span></a>' "$TARGET_DIR/de/archive/index.html"
123150

124151
echo "# Build stability test"
125152

0 commit comments

Comments
 (0)