Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WingLim/hugo-tania.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWingLim <643089849@qq.com>2021-09-27 08:41:57 +0300
committerGitHub <noreply@github.com>2021-09-27 08:41:57 +0300
commit8ec313c01056504b578dab7b42e3beef26b1f170 (patch)
tree33c6486e4ae9cac5d8ec2bc2f1afaf1a6040bf33
parent909fc6a71677d9c3a1200070ff478058361223f0 (diff)
fix: auto detect archives url (#45)
* fix: auto find archives layout page * docs: simplify archives page example * docs: add archives layout page * docs: update README.md
-rw-r--r--README.md16
-rw-r--r--exampleSite/content/articles.md2
-rw-r--r--layouts/_default/index.html5
3 files changed, 19 insertions, 4 deletions
diff --git a/README.md b/README.md
index 3718e99..1bb263f 100644
--- a/README.md
+++ b/README.md
@@ -38,12 +38,26 @@ Use Hugo Extended version (recommended) if you want to:
## Installation
-In your site's root dir
+`cd` into your site's root dir.
+
+1. Add `hugo-tania` them as submodule.
```bash
git submodule add https://github.com/WingLim/hugo-tania themes/hugo-tania
```
+2. Add `articles` page with [archives](https://github.com/WingLim/hugo-tania/wiki/Layout#archives) layout.
+
+```bash
+cat > content/articles.md <<EOF
+---
+title: Articles
+subtitle: Posts, tutorials, snippets, musings, and everything else.
+layout: "archives"
+---
+EOF
+```
+
Edit your site config following [exampleSite/config.yaml](https://github.com/WingLim/hugo-tania/blob/main/exampleSite/config.yaml).
## Thanks to
diff --git a/exampleSite/content/articles.md b/exampleSite/content/articles.md
index c074db7..96bcf65 100644
--- a/exampleSite/content/articles.md
+++ b/exampleSite/content/articles.md
@@ -1,7 +1,5 @@
---
title: Articles
subtitle: Posts, tutorials, snippets, musings, and everything else.
-date: 2020-11-26
-type: section
layout: "archives"
---
diff --git a/layouts/_default/index.html b/layouts/_default/index.html
index 5b7a9e3..5c4c13b 100644
--- a/layouts/_default/index.html
+++ b/layouts/_default/index.html
@@ -29,12 +29,15 @@
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $projects := where .Site.RegularPages "Section" "projects" }}
{{ $pages = .Paginate ($pages) }}
+{{ $archivesPage := first 1 (where .Site.RegularPages "Layout" "eq" "archives") }}
<div class="container">
<section>
<h2>
Latest Articles
- <a class="section-button" href="/articles">View all</a>
+ {{ range $archivesPage }}
+ <a class="section-button" href="{{ .RelPermalink }}">View all</a>
+ {{ end }}
</h2>
<div class="posts">
{{ range $pages.Pages }}