Skip to content

Commit

Permalink
Issue-482: Fix for archive page displayed in latest post section (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-baiborodine authored Feb 1, 2023
1 parent 95f58b0 commit df1e688
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 14 deletions.
12 changes: 6 additions & 6 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@ disqusShortname = ""
# social media profile urls for the footer links
showSocialMedia = true

# show an archive link in the footer
showArchive = false

# archive grouping: "2006" by year, "2006-01" by month
archiveDateGrouping = "2006-01"

# define your links with FontAwesome 5 (only free icons are supported)
# all icons https://fontawesome.com/icons?d=gallery&m=free
# brand icons https://fontawesome.com/icons?d=gallery&s=brands&m=free
Expand All @@ -152,6 +146,12 @@ disqusShortname = ""
{ link = "https://github.com/Lednerb", icon = "fab fa-github" },
]

# show an archive link in the footer
showArchive = false

# archive grouping: "2006" by year, "2006-01" by month
archiveDateGrouping = "2006-01"

# credits line configuration
copyrightBy = "by Lednerb"
copyrightUseCurrentYear = true # set to true to always display the current year in the copyright
Expand Down
5 changes: 5 additions & 0 deletions exampleSite/content/archive.de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "Archivseite"
type: archive
excludeFromIndex: true
---
2 changes: 1 addition & 1 deletion exampleSite/content/archive.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Archive page"
title: "Archive Page"
type: archive
excludeFromIndex: true
---
8 changes: 6 additions & 2 deletions layouts/archive/single.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{{ define "main" }}
<div class="content">
<div class="article-wrapper u-cf single">
<a class="bubble" href="{{ "/archive/" | relLangURL}}">
{{ with .Site.GetPage "/archive" }}
<a class="bubble" href="{{ .Permalink }}">
<i class="fa fa-fw fa-archive"></i>
</a>
{{ end }}

<article class="article">
<div class="content">
<h1 class="article-title">{{ i18n "archive" }}</h1>
{{ with .Site.GetPage "/archive" }}
<h1 class="article-title">{{ .Title }}</h1>
{{ end }}
<div class="meta"></div>
<div class="archive-list">
{{ range (where .Site.RegularPages "Type" "not in" (slice "page" "archive" "status" ) ).GroupByPublishDate (.Site.Params.archiveDateGrouping | default "2006-01") }}
Expand Down
7 changes: 3 additions & 4 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="recent-posts">
<strong>{{ i18n "latestPosts" }}</strong>
<ul>
{{ $dontRender := (slice "page" "quote" "link" "status") }}
{{ $dontRender := (slice "page" "quote" "link" "status" "archive") }}
{{ range (first (.Site.Params.amountLatestPostsInFooter | default 7) (where (where .Site.Pages.ByPublishDate.Reverse ".Kind" "page") ".Type" "not in" $dontRender )) }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
Expand All @@ -19,7 +19,7 @@
{{ if and .Site.Taxonomies.categories (gt ( .Site.Params.amountCategoriesInFooter | default 7 ) 0 ) }}
<div class="categories">
{{ with .Site.GetPage "/categories" }}
<a href="{{ .Permalink }}"><strong>{{ .Title }}</strong></a>
<a href="{{ .Permalink }}"><strong>{{ i18n "categories" }}</strong></a>
{{ end }}

<ul>
Expand All @@ -38,7 +38,6 @@
{{ if .Site.Params.showSocialMedia | default true }}
<div class="external-profiles">
<strong>{{ i18n "socialMedia" }}</strong>

{{ range .Site.Params.socialMediaLinks }}
<a href="{{ .link }}" target="_blank" rel="{{ .rel }}"><em class="{{ .icon }}"></em></a>
{{ end }}
Expand All @@ -62,7 +61,7 @@
{{ if .Site.Params.showArchive | default true }}
<div class="archive">
{{ with .Site.GetPage "/archive" }}
<a href="{{ .Permalink }}"><strong>{{ .Title }}</strong></a>
<a href="{{ .Permalink }}"><strong>{{ i18n "archive" }}</strong></a>
{{ end }}
</div>
{{ end }}
Expand Down
6 changes: 6 additions & 0 deletions testing/testing-example-site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ disqusShortname = "bilberry-hugo-theme"
{ link = "https://github.com/Lednerb", icon = "fab fa-github" },
]

# show an archive link in the footer
showArchive = true

# archive grouping: "2006" by year, "2006-01" by month
archiveDateGrouping = "2006-01"

# credits line configuration
copyrightBy = "by Lednerb"
copyrightUseCurrentYear = false # set to true to always display the current year in the copyright
Expand Down
5 changes: 5 additions & 0 deletions testing/testing-example-site/content/archive.de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "Archivseite"
type: archive
excludeFromIndex: true
---
5 changes: 5 additions & 0 deletions testing/testing-example-site/content/archive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "Archive Page"
type: archive
excludeFromIndex: true
---
29 changes: 28 additions & 1 deletion testing/testing-example-site/test-theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ testFolderAndContinue "$TARGET_DIR/de/tags/c++"
testFolderAndContinue "$TARGET_DIR/tags/tästing++"
testFolderAndContinue "$TARGET_DIR/de/tags/tästing++"

testFolderAndContinue "$TARGET_DIR/archive"
testFolderAndContinue "$TARGET_DIR/de/archive"

# article/täst [en]
echo "## Testing article/täst [en]"
testContentAndContinue '<a href="https://example.com/categories/t%C3%A4st&#43;&#43;/">Täst&#43;&#43;</a>' "$TARGET_DIR/article/täst/index.html"
Expand All @@ -96,7 +99,7 @@ testContentAndContinue '<a href="https://example.com/de/article/t%C3%A4st/">de</
testContentAndContinue '<a href="https://example.com/article/t%C3%A4st/">Umlauts Täst&#43;&#43;</a>' "$TARGET_DIR/article/täst/index.html"
testContentAndContinue '<p>This is a umlauts-test in Quotes äüöß++</p>' "$TARGET_DIR/quote/index.html"
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"

testContentAndContinue '<a href="https://example.com/archive/"><strong>Archive</strong></a>' "$TARGET_DIR/article/täst/index.html"
# article/täst [de]
echo "## Testing article/täst [de]"
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"
Expand All @@ -107,6 +110,7 @@ testContentAndContinue '<a href="https://example.com/article/t%C3%A4st/">en</a>'
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"
testContentAndContinue '<p>de This is a umlauts-test in quotes äüöß++</p>' "$TARGET_DIR/de/quote/index.html"
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"
testContentAndContinue '<a href="https://example.com/de/archive/"><strong>Archiv</strong></a>' "$TARGET_DIR/de/article/täst/index.html"

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

# archive [en]
echo "## Testing archive [en]"
testContentAndContinue '<a class="bubble" href="https://example.com/archive/">' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<h1 class="article-title">Archive Page</h1>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<h4>2020-05</h4>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<a href="https://example.com/article/long-text/">long text <span>(2020-05-15)</span></a>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<h4>2020-04</h4>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<a href="https://example.com/article/long-text-1/">long text 1 <span>(2020-04-15)</span></a>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<h4>2020-03</h4>' "$TARGET_DIR/archive/index.html"
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"
testContentAndContinue '<h4>2020-02</h4>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<a href="https://example.com/article/shorttextwithcode/">long text <span>(2020-02-15)</span></a>' "$TARGET_DIR/archive/index.html"
testContentAndContinue '<h4>2020-01</h4>' "$TARGET_DIR/archive/index.html"
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"
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"

# archive [de]
echo "## Testing archive [de]"
testContentAndContinue '<a class="bubble" href="https://example.com/de/archive/">' "$TARGET_DIR/de/archive/index.html"
testContentAndContinue '<h1 class="article-title">Archivseite</h1>' "$TARGET_DIR/de/archive/index.html"
testContentAndContinue '<h4>2020-01</h4>' "$TARGET_DIR/de/archive/index.html"
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"
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"

echo "# Build stability test"

Expand Down

0 comments on commit df1e688

Please sign in to comment.