mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-12-26 12:42:19 +00:00
update draft
This commit is contained in:
parent
f5f10845b4
commit
64404bdf0c
1 changed files with 168 additions and 43 deletions
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: "The Slash Page Scoop"
|
||||
date: 2024-05-30
|
||||
date: 2024-06-02
|
||||
# lastmod: 2024-05-30
|
||||
draft: true
|
||||
description: "I've added new slash pages to the site to share some background info on who I am, what I use, and how this site works."
|
||||
|
@ -30,6 +30,8 @@ And, of course, these are collected in one place at [/slashes](/slashes).
|
|||
|
||||
Feel free to stop here if you just want to check out the slash pages, or keep on reading for some nerd stuff about how I implemented them on my Hugo site.
|
||||
|
||||
---
|
||||
|
||||
### Implementation
|
||||
All of my typical blog posts get created within the site's Hugo directory under `content/posts/`, like this one at `content/posts/the-slash-page-scoop/index.md`. They get indexed, automatically added to the list of posts on the home page, and show up in the RSS feed. I don't want my slash pages to get that treatment so I made them directly inside the `content` directory:
|
||||
|
||||
|
@ -135,63 +137,186 @@ So instead of rendering the `description` I defined in the front matter the arch
|
|||
|
||||
> *My collection of [slash pages](https://slashpages.net).*
|
||||
|
||||
While I'm at it, I'd like for the slash pages themselves to be listed in alphabetical order rather than sorted by date (like everything else on the site). The rest of my `layouts/partials/archive.html` already handles a few different ways of displaying lists of content:
|
||||
While I'm at it, I'd like for the slash pages themselves to be listed in alphabetical order rather than sorted by date (like everything else on the site). The remainder of my `layouts/partials/archive.html` already handles a few different ways of displaying lists of content:
|
||||
|
||||
```jinja-html
|
||||
# torchlight! {"lineNumbers":true}
|
||||
{{- if eq .Kind "taxonomy" }} <!-- [tl! reindex(15) ] -->
|
||||
{{- if eq .Title "Tags" }} <!-- [tl! **:1 ] -->
|
||||
{{/* list of all tags */}}
|
||||
<div class="tagsArchive">
|
||||
{{- range $key, $value := .Site.Taxonomies }}
|
||||
{{- $slicedTags := ($value.ByCount) }}
|
||||
{{- range $slicedTags }}
|
||||
{{- if eq $key "tags"}}
|
||||
<div><a href='/{{ $key }}/{{ (replace .Name "#" "%23") | urlize }}/' title="{{ .Name }}">{{ .Name }}</a><sup>{{ .Count }} </sup></div> <!-- [tl! ** ] -->
|
||||
{{- end }}
|
||||
{{- if and (eq .Kind "taxonomy") (eq .Title "Tags") }} <!-- [tl! reindex(15)] -->
|
||||
{{/* /tags/ */}}
|
||||
<div class="tagsArchive">
|
||||
{{- range $key, $value := .Site.Taxonomies }}
|
||||
{{- $slicedTags := ($value.ByCount) }}
|
||||
{{- range $slicedTags }}
|
||||
{{- if eq $key "tags"}}
|
||||
<div><a href='/{{ $key }}/{{ (replace .Name "#" "%23") | urlize }}/' title="{{ .Name }}">{{ .Name }}</a><sup>{{ .Count }}</sup></div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- else }}
|
||||
{{/* list of all categories */}} <!-- [tl! ** ] -->
|
||||
{{- range .Pages.ByDate.Reverse }}
|
||||
{{- $postDate := .Date.Format "2006-01-02" }}
|
||||
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
|
||||
<article class="post">
|
||||
<header class="post__header">
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
<p class="post__meta">
|
||||
<span class="date">["{{ with $updateDate }}{{ . }}{{ else }}{{ .$postDate }}{{ end }}"]</span> <!-- [tl! ** ] -->
|
||||
</p>
|
||||
</header>
|
||||
<section class="post__summary">
|
||||
{{ .Description }} <!-- [tl! ** ] -->
|
||||
</section>
|
||||
<hr>
|
||||
</article>
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{/* regular posts archive */}} <!-- [tl! ** ] -->
|
||||
{{- range (.Paginate $pages).Pages }}
|
||||
</div>
|
||||
{{- else if eq .Kind "taxonomy" }}
|
||||
{{/* /categories/ */}}
|
||||
{{- $sorted := sort $pages "Title" }}
|
||||
{{- range $sorted }}
|
||||
{{- $postDate := .Date.Format "2006-01-02" }}
|
||||
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
|
||||
<article class="post">
|
||||
<header class="post__header">
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
<p class="post__meta">
|
||||
<span class="date">["{{- $postDate }}"{{- if ne $postDate $updateDate }}, "{{ $updateDate }}"{{ end }}]</span> <!-- [tl! ** ] -->
|
||||
</p>
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
<p class="post__meta">
|
||||
<span class="date">["{{ with $updateDate }}{{ . }}{{ else }}{{ $postDate }}{{ end }}"]</span>
|
||||
</p>
|
||||
</header>
|
||||
<section class="post__summary">
|
||||
{{if .Description }}{{ .Description }}{{ else }}{{ .Summary }}{{ end }} <!-- [tl! ** ] -->
|
||||
{{ .Description }}
|
||||
</section>
|
||||
<hr>
|
||||
</article>
|
||||
{{- end }}
|
||||
{{- template "_internal/pagination.html" . }}
|
||||
{{ end }}
|
||||
{{- else }}
|
||||
{{/* regular posts archive */}}
|
||||
{{- range (.Paginate $pages).Pages }}
|
||||
{{- $postDate := .Date.Format "2006-01-02" }}
|
||||
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
|
||||
<article class="post">
|
||||
<header class="post__header">
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
<p class="post__meta">
|
||||
<span class="date">["{{- $postDate }}"{{- if ne $postDate $updateDate }}, "{{ $updateDate }}"{{ end }}]</span>
|
||||
</p>
|
||||
</header>
|
||||
<section class="post__summary">
|
||||
{{if .Description }}{{ .Description }}{{ else }}{{ .Summary }}{{ end }}
|
||||
</section>
|
||||
<hr>
|
||||
</article>
|
||||
{{- end }}
|
||||
{{- template "_internal/pagination.html" . }}
|
||||
{{- end }}
|
||||
```
|
||||
|
||||
1. The [tags](/tags/) archive (list of all tags) uses a very condensed format for displaying all the tags in one place.
|
||||
2. Other archives of taxonomy pages (like the list of all [categories](/categories/)) have the
|
||||
1. The [/tags/](/tags/) archive uses a condensed display format which simply shows the tag name and the number of posts with that tag.
|
||||
2. Other taxonomy archives (like [/categories](/categories)) are sorted by title, displayed with a brief description, and the date that a post in the categories was published or updated.
|
||||
3. Archives of posts are sorted by date (most recent first) and include the post description (or summary if it doesn't have one), and both the publish and updated dates.
|
||||
|
||||
I'll just tweak the second condition there to check for either a taxonomy archive or a page with the title `/slashes`:
|
||||
|
||||
```jinja-html
|
||||
# torchlight! {"lineNumbers":true}
|
||||
{{- if and (eq .Kind "taxonomy") (eq .Title "Tags") }} <!-- [tl! collapse:start reindex(20)] -->
|
||||
{{/* /tags/ */}}
|
||||
<div class="tagsArchive">
|
||||
{{- range $key, $value := .Site.Taxonomies }}
|
||||
{{- $slicedTags := ($value.ByCount) }}
|
||||
{{- range $slicedTags }}
|
||||
{{- if eq $key "tags"}}
|
||||
<div><a href='/{{ $key }}/{{ (replace .Name "#" "%23") | urlize }}/' title="{{ .Name }}">{{ .Name }}</a><sup>{{ .Count }}</sup></div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }} <!-- [tl! collapse:end] -->
|
||||
</div>
|
||||
{{- else if eq .Kind "taxonomy" }} <!-- [tl! **:3 --] -->
|
||||
{{- else if or (eq .Kind "taxonomy") (eq .Title "/slashes") }} <!-- [tl! ++ reindex(-1)] -->
|
||||
{{/* /categories/ */}} <!-- [tl! --] -->
|
||||
{{/* /categories/ or /slashes/ */}} <!-- [tl! ++ reindex(-1)] -->
|
||||
{{- $sorted := sort $pages "Title" }}
|
||||
{{- range $sorted }}
|
||||
{{- $postDate := .Date.Format "2006-01-02" }}
|
||||
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
|
||||
<article class="post">
|
||||
<header class="post__header">
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
<p class="post__meta">
|
||||
<span class="date">["{{ with $updateDate }}{{ . }}{{ else }}{{ $postDate }}{{ end }}"]</span>
|
||||
</p>
|
||||
</header>
|
||||
<section class="post__summary">
|
||||
{{ .Description }}
|
||||
</section>
|
||||
<hr>
|
||||
</article>
|
||||
{{ end }}
|
||||
{{- else }} <!-- [tl! collapse:start] -->
|
||||
{{/* regular posts archive */}}
|
||||
{{- range (.Paginate $pages).Pages }}
|
||||
{{- $postDate := .Date.Format "2006-01-02" }}
|
||||
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
|
||||
<article class="post">
|
||||
<header class="post__header">
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
|
||||
<p class="post__meta">
|
||||
<span class="date">["{{- $postDate }}"{{- if ne $postDate $updateDate }}, "{{ $updateDate }}"{{ end }}]</span>
|
||||
</p>
|
||||
</header>
|
||||
<section class="post__summary">
|
||||
{{if .Description }}{{ .Description }}{{ else }}{{ .Summary }}{{ end }}
|
||||
</section>
|
||||
<hr>
|
||||
</article>
|
||||
{{- end }}
|
||||
{{- template "_internal/pagination.html" . }}
|
||||
{{- end }} <!-- [tl! collapse:end] -->
|
||||
```
|
||||
|
||||
So that's got the [/slashes](/slashes/) page looking the way I want it to. The last tweak will be to the template I use for displaying related (ie, in the same category) posts in the sidebar. The magic for that happens in `layouts/partials/aside.html`:
|
||||
|
||||
```jinja-html
|
||||
# torchlight! {"lineNumbers":true}
|
||||
{{ if .Params.description }}<p>{{ .Params.description }}</p><hr>{{ end }} <!-- [tl! collapse:start] -->
|
||||
{{ if and (gt .WordCount 400 ) (gt (len .TableOfContents) 180) }}
|
||||
<p>
|
||||
<h3>On this page</h3>
|
||||
{{ .TableOfContents }}
|
||||
<hr>
|
||||
</p>
|
||||
{{ end }} <!-- [tl! collapse:end] -->
|
||||
|
||||
{{ if isset .Params "categories" }} <!--[tl! **:start] -->
|
||||
{{$related := where .Site.RegularPages ".Params.categories" "eq" .Params.categories }}
|
||||
{{- $relatedLimit := default 8 .Site.Params.numberOfRelatedPosts }}
|
||||
{{ if eq .Params.categories "slashes" }} <!-- [tl! ++:10] -->
|
||||
<h3>More /slashes</h3>
|
||||
{{ $sortedPosts := sort $related "Title" }}
|
||||
<ul>
|
||||
{{- range $sortedPosts }}
|
||||
<li>
|
||||
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title | markdownify }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ else }}
|
||||
<h3>More {{ .Params.categories }}</h3>
|
||||
<ul>
|
||||
{{- range first $relatedLimit $related }}
|
||||
<li>
|
||||
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title | markdownify }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if gt (len $related) $relatedLimit }}
|
||||
<li>
|
||||
<a href="/categories/{{ lower .Params.categories }}/"><i>See all {{ .Params.categories }}</i></a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }} <!-- [tl! ++ **:end] -->
|
||||
<hr>
|
||||
{{ end }}
|
||||
|
||||
{{- $posts := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} <!-- [tl! collase:12] -->
|
||||
{{- $featured := default 8 .Site.Params.numberOfFeaturedPosts }}
|
||||
{{- $featuredPosts := first $featured (where $posts "Params.featured" true)}}
|
||||
{{- with $featuredPosts }}
|
||||
<h3>Featured Posts</h3>
|
||||
<ul>
|
||||
{{- range . }}
|
||||
<li>
|
||||
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title | markdownify }}</a>
|
||||
</li>
|
||||
{{- end }}
|
||||
</ul>
|
||||
{{- end }}
|
||||
```
|
||||
|
||||
So now if you visit any of my slash pages (like, say, [/colophon](/colophon/)) you'll see the alphabetized list of other slash pages in the side bar.
|
||||
|
||||
### Closing
|
||||
I'll probably keep tweaking these slash pages in the coming days, but for now I'm really glad to finally have them posted. I've only thinking about doing this for the past six months.
|
Loading…
Reference in a new issue