Skip to content

Commit

Permalink
fix: auto detect archives url (#45)
Browse files Browse the repository at this point in the history
* fix: auto find archives layout page

* docs: simplify archives page example

* docs: add archives layout page

* docs: update README.md
  • Loading branch information
WingLim authored Sep 27, 2021
1 parent 909fc6a commit 8ec313c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions exampleSite/content/articles.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: Articles
subtitle: Posts, tutorials, snippets, musings, and everything else.
date: 2020-11-26
type: section
layout: "archives"
---
5 changes: 4 additions & 1 deletion layouts/_default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 8ec313c

Please sign in to comment.