Use prettier, more resilient tag listing for WWW

And document requirements in the readme
This commit is contained in:
hedy 2024-04-11 18:25:50 +08:00
parent 7346846c71
commit 858544b7d6
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
11 changed files with 58 additions and 22 deletions

View File

@ -2,6 +2,8 @@ HUGO=hugo
HUGO_CACHEDIR=~/hugo_cache
HUGO_FLAGS=--cleanDestinationDir
PRETTIER=prettier
RSYNC=rsync
RSYNC_FLAGS=-a
@ -55,6 +57,7 @@ html:
$(RSYNC) $(RSYNC_FLAGS) public/ --exclude '*.gmi' --exclude gemini $(HTML_DEST)
@# Manually include gemini tag (because it was excluded above)
$(RSYNC) $(RSYNC_FLAGS) public/tags/gemini $(HTML_DEST)/tags/
$(PRETTIER) --write $(HTML_DEST)"/**/*.html"
finish-clean:
rm -rf $(GEMINI_DEST)-back $(HTML_DEST)-back

View File

@ -20,8 +20,35 @@ design. It has a few custom colors, a sans-serif font stack, and some styling in
the footer and nav. Everything else is partially based on top of [simple
css](https://simplecss.org) and sometimes [seirdy's site](https://seirdy.one).
## requirements
### build
- **hugo** - generate files
- **rsync** - separate HTML & gemini files into dedicated destinations
perhaps I'll just switch to plain copying in the future. This was a relic of
the old deployment system where I kept some extra files (such as CGI scripts)
in the destination which should not be deleted.
what this means is that I'll have to do `rm -rf DEST/*` periodically to clean
up old files
- **python3** - postprocessing on the gemini files
- **prettier** - format HTML files
this requires my template HTMl files not rely on newline for spacing.
to test, simply remove the prettier command from Makefile, run `make gen &&
mkdir public2 && cp -r public public2` and run prettier on `public2`, make
sure everything in `public2` looks the same as `public`.
### deploy
- **hut** - publishes HTML/gemini files to srht.site
## hardcoded values
### resources
In WWW, posts' resources are stored under the same directory as the post:
- `/posts/my-slug/index.html` (the post itself)
- `/posts/my-slug/resource-1.png`
@ -40,28 +67,26 @@ These files might need to be changed to customize this:
- [x] let gemini version also have a post page at /posts/index.gmi
- [ ] minify images and use WebP
- [ ] lint
- [ ] better a11y
- [x] provide atom feed for www
- [x] show post description in list
- [ ] proper reply via email link
## writing
## Workflows
### posts
```sh
bin/post
```
## deploy
resources should be put in the same directory as the post. Link to them within
markdown ad gemini files using the `get-resource-link.{gmi|html}` shortcode
which returns the relative permalink of the file. (see [resources](#resources).)
Also see [gemcgi](https://git.sr.ht/~hedy/gemcgi)
### deploy
```sh
make all deploy
```
### twtxt
Hardcodes destination host and gemini directory.
```sh
bin/twt
```

View File

@ -2,6 +2,7 @@
{{ $title := slicestr (replace .Name "-" " ") 11 -}}
title = {{ $title | title }}
description = {{ strings.FirstUpper $title }}
tags = []
highlight = false
draft = true

View File

@ -3,7 +3,7 @@ date = '2021-02-05T01:44:15Z'
description = "I'm alive!"
draft = false
outputs = ['html', 'gemtext']
tags = ['test']
tags = []
title = 'Hello world'
slug = 'hello'
+++

View File

@ -3,6 +3,7 @@ date = '2021-02-23'
description = 'A walkthrough of my workflows for the site and a gentle introduction to tilde.cafe and the Tildeverse.'
draft = false
outputs = ['html', 'gemtext']
tags = ['meta']
slug = 'site-meta'
title = 'How this site works'
+++

View File

@ -5,7 +5,7 @@ draft = false
highlight = true
outputs = ['html', 'gemtext']
slug = 'multiple-emails-git'
tags = ['git', 'howto']
tags = ['howto', 'git']
title = 'Managing multiple emails for git across different computers'
+++

View File

@ -5,7 +5,7 @@ draft = false
highlight = true
outputs = ['html', 'gemtext']
slug = 'hugo-syntax-highlighting'
tags = ['howto']
tags = ['howto', 'hugo']
title = 'Setting up syntax highlighting for Hugo'
+++

View File

@ -5,7 +5,7 @@ draft = false
footnotes_heading = 'Footnotes'
outputs = ['html', 'gemtext']
slug = 'vim-column-editing'
tags = ['howto']
tags = ['howto', 'terminal']
title = 'Vim visual block mode for column editing'
EOF = false
+++

View File

@ -31,8 +31,8 @@
{{ end -}}
<p class="post-meta">
<time datetime="{{ .Date.Format "2006-01-02 15:04:05Z07:00" }}">{{ .Date.Format "Jan 02, 2006" }}</time>
&nbsp;·&nbsp; {{ partial "tags.html" . }}
</p>
{{- partial "tags.html" (dict "Page" . "Prefix" "&nbsp; · &nbsp;") -}}
</p>
<p class="desc">{{ .Description }}</p>
</li>
{{- end }}

View File

@ -1,5 +1,11 @@
{{ $taxonomy := "tags" -}}
{{ with .Param $taxonomy -}}<span class="tags">
{{ range $index, $tag := . -}}{{- with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
{{- if $index -}}, {{ end -}}<a href="{{ .RelPermalink }}">{{ $tag | urlize }}</a>{{- end -}}{{- end }}
</span>{{- end -}}
{{ $tags := .Page.Param $taxonomy -}}
{{ if (len $tags) -}}
{{ with $.Prefix }}{{ . | safeHTML -}}{{ end -}}
<span class="tags">
{{- range $index, $tag := $tags -}}
{{- $taglink := $.Page.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
{{- if $index -}}, {{ end -}}<a href="{{ $taglink.RelPermalink }}">{{ $tag | urlize }}</a>
{{- end }}
</span>
{{- end }}

View File

@ -6,7 +6,7 @@
<div class="post-meta">
<p>
<time itemprop="datePublished" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "Jan 02, 2006" }}</time>
{{ partial "lastmod.html" (dict "Page" . "Prefix" "&nbsp;·&nbsp;" ) }}
{{- partial "lastmod.html" (dict "Page" . "Prefix" "&nbsp; · &nbsp;" ) }}
&nbsp;·&nbsp; {{ .WordCount }} words
</p>
<hr>