mirror of
https://github.com/foo-dogsquared/hugo-theme-more-contentful.git
synced 2025-01-31 04:58:14 +00:00
402 lines
15 KiB
HTML
402 lines
15 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en-us">
|
||
<head><title>Creating an archive page | More Contentful</title>
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="/hugo-theme-more-contentful/css/main.min.f918d3cd493489e84ce3292da6ca269d636130e432857876b773aa1d6560ae5d.css" /><script>
|
||
let theme = window.localStorage.getItem('theme');
|
||
if (theme) {
|
||
document.documentElement.dataset.theme = theme;
|
||
}
|
||
</script>
|
||
|
||
<link rel="shortcut icon" href="/hugo-theme-more-contentful/%20favicon.png" />
|
||
|
||
<meta name="generator" content="Hugo 0.138.0">
|
||
<meta charset="utf-8">
|
||
<meta name="author" content="John Doe" />
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<meta name="referrer" content="no-referrer" />
|
||
<meta name="description" content="
|
||
This will add an archive page similar to archive pages like these.
|
||
|
||
|
||
|
||
{{- define "main" -}}
|
||
|
||
<h1>{{ .Title }}</h1>
|
||
|
||
{{ .Content }}
|
||
|
||
<hr>
|
||
|
||
{{- /* Creating a section that lists out regular pages by year */ -}}
|
||
{{ range $.Site.RegularPages.GroupByPublishDate "2006" }}
|
||
{{- /* Skip regular pages with an invalid creation date string. */ -}}
|
||
{{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter. */ -}}
|
||
{{- /* We will also exclude hidden pages. */ -}}
|
||
{{ if ne .Key "0001" }}
|
||
<section data-year="{{ .Key }}">
|
||
<h2 id="{{ .Key }}">{{ .Key }}</h2>
|
||
<ul>
|
||
{{- range where .Pages "Params.hidden" "!=" true -}}
|
||
<li>
|
||
<date>{{ .Date.Format "2006-01-02" }}</date> -
|
||
<a aria-label="{{ .Title }}" href="{{ .Permalink }}">{{ .Title }}</a>
|
||
</li>
|
||
{{- end -}}
|
||
</ul>
|
||
</section>
|
||
{{- end }}
|
||
{{ end }}
|
||
|
||
{{- end -}}
|
||
" />
|
||
<meta name="twitter:card" content="summary">
|
||
<meta name="twitter:title" content="Creating an archive page">
|
||
<meta name="twitter:description" content="This will add an archive page similar to archive pages like these.
|
||
{{- define "main" -}} <h1>{{ .Title }}</h1> {{ .Content }} <hr> {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate "2006" }} {{- /* Skip regular pages with an invalid creation date string. */ -}} {{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter. */ -}} {{- /* We will also exclude hidden pages. */ -}} {{ if ne .Key "0001" }} <section data-year="{{ .Key }}"> <h2 id="{{ .Key }}">{{ .Key }}</h2> <ul> {{- range where .Pages "Params.hidden" "!=" true -}} <li> <date>{{ .Date.Format "2006-01-02" }}</date> - <a aria-label="{{ .Title }}" href="{{ .Permalink }}">{{ .Title }}</a> </li> {{- end -}} </ul> </section> {{- end }} {{ end }} {{- end -}}">
|
||
<meta property="og:url" content="https://foo-dogsquared.github.io/hugo-theme-more-contentful/recipes/creating-an-archive-page/">
|
||
<meta property="og:site_name" content="More Contentful">
|
||
<meta property="og:title" content="Creating an archive page">
|
||
<meta property="og:description" content="This will add an archive page similar to archive pages like these.
|
||
{{- define "main" -}} <h1>{{ .Title }}</h1> {{ .Content }} <hr> {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate "2006" }} {{- /* Skip regular pages with an invalid creation date string. */ -}} {{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter. */ -}} {{- /* We will also exclude hidden pages. */ -}} {{ if ne .Key "0001" }} <section data-year="{{ .Key }}"> <h2 id="{{ .Key }}">{{ .Key }}</h2> <ul> {{- range where .Pages "Params.hidden" "!=" true -}} <li> <date>{{ .Date.Format "2006-01-02" }}</date> - <a aria-label="{{ .Title }}" href="{{ .Permalink }}">{{ .Title }}</a> </li> {{- end -}} </ul> </section> {{- end }} {{ end }} {{- end -}}">
|
||
<meta property="og:locale" content="en_us">
|
||
<meta property="og:type" content="article">
|
||
<meta property="article:section" content="recipes">
|
||
<meta property="article:published_time" content="2020-10-20T20:36:55+08:00">
|
||
<meta property="article:modified_time" content="2020-10-20T20:36:55+08:00">
|
||
|
||
<meta itemprop="name" content="Creating an archive page">
|
||
<meta itemprop="description" content="This will add an archive page similar to archive pages like these.
|
||
{{- define "main" -}} <h1>{{ .Title }}</h1> {{ .Content }} <hr> {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate "2006" }} {{- /* Skip regular pages with an invalid creation date string. */ -}} {{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter. */ -}} {{- /* We will also exclude hidden pages. */ -}} {{ if ne .Key "0001" }} <section data-year="{{ .Key }}"> <h2 id="{{ .Key }}">{{ .Key }}</h2> <ul> {{- range where .Pages "Params.hidden" "!=" true -}} <li> <date>{{ .Date.Format "2006-01-02" }}</date> - <a aria-label="{{ .Title }}" href="{{ .Permalink }}">{{ .Title }}</a> </li> {{- end -}} </ul> </section> {{- end }} {{ end }} {{- end -}}">
|
||
<meta itemprop="datePublished" content="2020-10-20T20:36:55+08:00">
|
||
<meta itemprop="dateModified" content="2020-10-20T20:36:55+08:00">
|
||
<meta itemprop="wordCount" content="233">
|
||
<meta itemprop="keywords" content="Recipe"><link rel="canonical" type="text/html" href="/hugo-theme-more-contentful/recipes/creating-an-archive-page/" />
|
||
|
||
</head>
|
||
<body><header aria-label="Site header">
|
||
<nav class="site__nav-header">
|
||
<a class="site__title" href="/hugo-theme-more-contentful/">More Contentful</a>
|
||
<ul class="site__list">
|
||
|
||
<li>
|
||
<a href="/hugo-theme-more-contentful/about/">About</a>
|
||
</li>
|
||
<li>
|
||
<a href="/hugo-theme-more-contentful/categories/">Categories</a>
|
||
</li>
|
||
<li>
|
||
<a href="/hugo-theme-more-contentful/recipes/">Recipes</a>
|
||
</li>
|
||
<li>
|
||
<a href="/hugo-theme-more-contentful/tags/">Tags</a>
|
||
</li>
|
||
|
||
|
||
</ul>
|
||
</nav>
|
||
<div class="site__theme-btn" aria-label="Theme toggle" aria-hidden="true">
|
||
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/generic/swatch.svg#swatch"></use>
|
||
</svg>
|
||
|
||
<div class="site__theme-dropdown">
|
||
<div class="site__theme-dropdown-list">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Default Dark"
|
||
data-theme-dark
|
||
|
||
>Dark</div>
|
||
|
||
|
||
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Default Light"
|
||
|
||
data-theme-light
|
||
>Light</div>
|
||
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Dracula"
|
||
|
||
|
||
>Dracula</div>
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Gruvbox dark, hard"
|
||
|
||
|
||
>Gruvbox dark, hard</div>
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Gruvbox light, hard"
|
||
|
||
|
||
>Gruvbox light, hard</div>
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Nord"
|
||
|
||
|
||
>Nord</div>
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Solarized Dark"
|
||
|
||
|
||
>Solarized Dark</div>
|
||
|
||
|
||
<div class="site__theme-item"
|
||
data-theme="Solarized Light"
|
||
|
||
|
||
>Solarized Light</div>
|
||
|
||
<div class="site__theme-item" data-theme-system>
|
||
OS default
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
function styleTheme() {
|
||
const selectedTheme = window.localStorage.getItem("theme");
|
||
for (const el of document.querySelectorAll(".site__theme-item")) {
|
||
if (el.dataset.theme == selectedTheme) {
|
||
el.classList.add("site__theme-item--selected");
|
||
} else {
|
||
el.classList.remove("site__theme-item--selected");
|
||
}
|
||
}
|
||
}
|
||
|
||
const themeDropdown = document.querySelector('.site__theme-btn');
|
||
themeDropdown.addEventListener('click', (event) => {
|
||
const { target } = event;
|
||
if (target.classList.contains("site__theme-item")) {
|
||
if (target.dataset.theme) {
|
||
theme = target.dataset.theme;
|
||
window.localStorage.setItem("theme", theme);
|
||
document.documentElement.dataset.theme = theme;
|
||
} else {
|
||
window.localStorage.removeItem("theme");
|
||
delete document.documentElement.dataset.theme;
|
||
}
|
||
}
|
||
|
||
styleTheme();
|
||
});
|
||
|
||
styleTheme();
|
||
</script>
|
||
|
||
</header>
|
||
<hr aria-hidden="true"/>
|
||
|
||
<div class="post--single">
|
||
<main>
|
||
<article>
|
||
<header>
|
||
<h1>Creating an archive page</h1>
|
||
|
||
<div class="site__list post__meta" aria-hidden="true"><span class="post__meta-icon-label">
|
||
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/generic/calendar.svg#calendar"></use>
|
||
</svg>
|
||
|
||
<time datetime="2020-10-20T20:36:55+08:00" title="Created">
|
||
2020-10-20
|
||
</time>
|
||
</span>
|
||
</div>
|
||
|
||
</header>
|
||
|
||
|
||
|
||
|
||
<div class="paragraph">
|
||
<p>This will add an archive page similar to archive pages <a href="https://davidtranscend.com/archives/">like</a> <a href="https://lukesmith.xyz/blogindex.html">these</a>.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="highlight"><code class="language-go" data-lang="go">{{- define "main" -}}
|
||
|
||
<h1>{{ .Title }}</h1>
|
||
|
||
{{ .Content }}
|
||
|
||
<hr>
|
||
|
||
{{- /* Creating a section that lists out regular pages by year */ -}}
|
||
{{ range $.Site.RegularPages.GroupByPublishDate "2006" }}
|
||
{{- /* Skip regular pages with an invalid creation date string. */ -}}
|
||
{{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter. */ -}}
|
||
{{- /* We will also exclude hidden pages. */ -}}
|
||
{{ if ne .Key "0001" }}
|
||
<section data-year="{{ .Key }}">
|
||
<h2 id="{{ .Key }}">{{ .Key }}</h2>
|
||
<ul>
|
||
{{- range where .Pages "Params.hidden" "!=" true -}}
|
||
<li>
|
||
<date>{{ .Date.Format "2006-01-02" }}</date> -
|
||
<a aria-label="{{ .Title }}" href="{{ .Permalink }}">{{ .Title }}</a>
|
||
</li>
|
||
{{- end -}}
|
||
</ul>
|
||
</section>
|
||
{{- end }}
|
||
{{ end }}
|
||
|
||
{{- end -}}</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We will simply add this as a layout in our customized theme.
|
||
Let’s call it <code>archives</code> so we have to add a file in <code>layouts/_default/archives.html</code> then set a page of our project with the <code>layout</code> key in the frontmatter.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We want the archives page to be accessed at <code>$.Site.BaseURL/archives</code> so we’ll simply create <code>archives.adoc</code> (<a href="https://gohugo.io/content-management/formats/#list-of-content-formats">any valid content files with certain file extensions can do</a>, I’m using <a href="https://asciidoctor.org/">Asciidoctor</a>) with the following example content.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="highlight"><code class="language-asciidoctor" data-lang="asciidoctor">---
|
||
title: "Archives"
|
||
layout: "archive"
|
||
---
|
||
|
||
= Archives
|
||
|
||
This is the archives of the century.</code></pre>
|
||
</div>
|
||
</div>
|
||
|
||
</article>
|
||
</main>
|
||
|
||
|
||
<hr aria-hidden="true"/>
|
||
<div class="post__meta--single" aria-hidden="true">
|
||
|
||
|
||
|
||
<p data-content-publication-date="2020-10-20T20:36:55+08:00">Created: <time datetime="2020-10-20T20:36:55+08:00">2020-10-20</time></p>
|
||
|
||
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
|
||
<hr aria-hidden="true"/><footer aria-label="Site footer">
|
||
|
||
<a href="#top">Back to top</a>
|
||
|
||
|
||
|
||
<p>Available in other languages:
|
||
<span class="site__list site__languages">
|
||
|
||
<a href="/hugo-theme-more-contentful/en" hreflang="en">English</a>
|
||
|
||
<a href="/hugo-theme-more-contentful/tl" hreflang="tl">Tagalog</a>
|
||
|
||
</span>
|
||
</p>
|
||
|
||
|
||
|
||
|
||
|
||
<nav class="site__list site__socials">
|
||
|
||
|
||
|
||
<a class="site__social-icon" rel="me" href="https://example.org/gmail" aria-label="E-mail">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/gmail.svg#gmail"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/keybase" aria-label="Keybase">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/keybase.svg#keybase"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/devdotto" aria-label="Dev.to">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/devdotto.svg#devdotto"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/github/" aria-label="GitHub">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/github.svg#github"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/gitlab" aria-label="GitLab">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/gitlab.svg#gitlab"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/lichess" aria-label="Lichess">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/lichess.svg#lichess"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/picartodottv" aria-label="Picarto.tv">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/picartodottv.svg#picartodottv"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/pixiv" aria-label="Pixiv">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/pixiv.svg#pixiv"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/twitch" aria-label="Twitch">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/twitch.svg#twitch"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/twitter" aria-label="X (formerly Twitter)">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/x.svg#x"></use>
|
||
</svg>
|
||
</a><a class="site__social-icon" rel="me" href="https://example.org/youtube" aria-label="YouTube">
|
||
<svg class="site__icon">
|
||
<use href="/hugo-theme-more-contentful/icons/brand/youtube.svg#youtube"></use>
|
||
</svg>
|
||
</a></nav>
|
||
|
||
|
||
|
||
|
||
|
||
<p>© 2024 More Contentful</p>
|
||
</footer>
|
||
|
||
</body>
|
||
</html>
|