Links have agree/accurate indicators (#7)

- Remove i18n & include drafts in dev build
- Links have agree/accurate indicators
- Also introduces `references` as a standard Params structure for my blog. I don't particularly like that it's a map rather than an array, but this is what my micropib enpoint currently creates, so I'll stick with this until I can be bothered to switch that over.
This commit is contained in:
JP Hastings-Spital 2024-02-22 08:25:18 +00:00 committed by GitHub
parent 7b271f38ac
commit 233e7c35af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 126 additions and 699 deletions

View file

@ -12,7 +12,7 @@ tasks:
- lychee --cache --suggest --require-https .
dev:
cmds:
- hugo server --minify
- hugo server --minify -D
build:
cmds:
- hugo --cacheDir /tmp/hugo/cache --minify --baseURL "https://www.byjp.me"

27
assets/scss/_links.scss Normal file
View file

@ -0,0 +1,27 @@
a[rel~="+agree"]:hover {
text-decoration-style: double;
}
a[rel~="-agree"]:hover {
text-decoration-style: dotted;
}
a[rel~="+accurate"]:hover {
position: relative;
&::after {
position: absolute;
vertical-align: super;
font-size: x-small;
content: "";
}
}
a[rel~="-accurate"]:hover {
position: relative;
&::after {
position: absolute;
vertical-align: super;
font-size: x-small;
content: "";
}
}

View file

@ -339,6 +339,11 @@ figure {
}
}
caption {
font-size: 0.8rem;
opacity: 0.6;
}
em, strong {
// Default
color: $light-color-variant;

View file

@ -31,6 +31,14 @@ $media-size-tablet: "(max-width: 900px)";
--tabletWidth: (max-width: 900px);
--accent: #8186FF;
--accentHue: 290;
@media (prefers-color-scheme: dark) {
--background: #232425;
}
@media (prefers-color-scheme: light) {
--background: #fff;
}
}
/* Content */

View file

@ -18,3 +18,4 @@
@import "tables";
@import "404";
@import "search";
@import "links";

View file

@ -6,6 +6,7 @@ bookmarkOf: https://invertedpassion.com/a-primer-on-dopamine/
references:
bookmark:
url: https://invertedpassion.com/a-primer-on-dopamine/
rel: +agree +accurate
type: entry
name: A primer on dopamine
summary: '1/ I recently made notes on the book "Hooked" but wasn''t satisfied
@ -13,6 +14,17 @@ references:
of habit-forming products and that inevitably lead me to the (in)famous neurotransmitter
dopamine. 3/ Before we dive into what dopamine does, let''s first make one thing
clear: dopamine…'
games-problems:
url: https://invertedpassion.com/games-are-problems-people-pay-to-solve/
name: Games are problems people pay to solve
rel: +agree +accurate
skimmable:
url: https://invertedpassion.com/why-you-will-skim-this-article/
name: Why you will skim this article
rel: +agree +accurate
dopamine-and-value-of-work:
url: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4696912/
name: Mesolimbic Dopamine Signals the Value of Work
---
I really enjoyed reading about dopamine, desire and pleasure here! Its worth a read, even if it slightly veers into the “how to abuse this knowledge for personal gain with your new product” space.

View file

@ -11,6 +11,11 @@ tags:
- colour
- picker
- colour-scheme
references:
lch-in-css:
url: https://lea.verou.me/blog/2020/04/lch-colors-in-css-what-why-and-how/
rel: +accurate
name: "LCH colors in CSS: what, why, and how?"
---
## Spelling

View file

@ -8,6 +8,15 @@ tags:
- zwj
- emoji
- fonts
references:
microsoft-ttf-docs:
url: https://learn.microsoft.com/en-us/typography/opentype/spec/
name: OpenType® Specification Version 1.9
rel: +accurate
apple-ttf-docs:
url: https://developer.apple.com/fonts/TrueType-Reference-Manual/
name: TrueType Reference Manual
rel: +accurate
---
## TTF Fonts

View file

@ -7,6 +7,11 @@ tags:
- shapes
- tiling
- colour
references:
chiral-aperiodic-monotile:
url: https://cs.uwaterloo.ca/~csk/spectre/
name: A chiral aperiodic monotile
rel: +accurate
---
## Aperiodic monotiles

View file

@ -6,6 +6,11 @@ tags:
- optimisation
- lines
- svg
references:
line-simplification:
url: https://bost.ocks.org/mike/simplify/
name: Line Simplification
rel: +accurate
---
## Line simplification

View file

@ -7,6 +7,11 @@ tags:
- manifesto
- play
- games
references:
puzmo-manifesto:
url: https://www.puzzmo.com/public-manifesto
name: The Puzzmo Manifesto
rel: +agree
---
## Puzzmo manifesto

View file

@ -1,39 +0,0 @@
# Translations for German
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Übersetzungen"
[postAvailable]
other = "Auch verfügbar auf"
# 404.html
#
[archives]
other = "Archiv"
[home]
other = "Home"
[notFound]
other = "Oops, Seite nicht gefunden ..."
# posts/single.html
#
[readingTime]
one = "Eine Minute"
other = "{{ .Count }} Minuten"
[tableOfContents]
other = "Inhaltsverzeichnis"
[wordCount]
one = "Ein Wort"
other = "{{ .Count }} Wörter"
[lastModified]
other = "Letzte Aktualisierung"

View file

@ -1,39 +0,0 @@
# Translations for Spanish
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traducciones"
[postAvailable]
other = "También disponible en"
# 404.html
#
[archives]
other = "Archivo"
[home]
other = "Home"
[notFound]
other = "Oops, página no encontrada…"
# posts/single.html
#
[readingTime]
one = "Un minuto"
other = "{{ .Count }} minutos"
[tableOfContents]
other = "Tabla de Contenido"
[wordCount]
one = "Una Palabra"
other = "{{ .Count }} Palabras"
[lastModified]
other = "Ultima actualización"

View file

@ -1,39 +0,0 @@
# Translations for French
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traductions"
[postAvailable]
other = "Aussi disponible en"
# 404.html
#
[archives]
other = "Les archives"
[home]
other = "Accueil"
[notFound]
other = "Oups, page non trouvée …"
# posts/single.html
#
[readingTime]
one = "Une minute"
other = "{{ .Count }} minutes"
[tableOfContents]
other = "Table des matières"
[wordCount]
one = "Un Mot"
other = "{{ .Count }} Mots"
[lastModified]
other = "Mise à jour"

View file

@ -1,36 +0,0 @@
# Translations for Galician
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traducións"
[postAvailable]
other = "Tamén dispoñible en"
# 404.html
#
[archives]
other = "Arquivos"
[home]
other = "Inicio"
[notFound]
other = "Vaia, non se atopou a páxina..."
# posts/single.html
#
[readingTime]
one = "Un minuto"
other = "{{ .Count }} minutos"
[tableOfContents]
other = "Táboa de contidos"
[wordCount]
one = "Unha Palabra"
other = "{{ .Count }} Palabras"

View file

@ -1,39 +0,0 @@
# Translations for Hindi
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "अनुवाद"
[postAvailable]
other = "पढ़ें इस भाषा में"
# 404.html
#
[archives]
other = "पुरालेख"
[home]
other = "घर"
[notFound]
other = "क्षमा करें ! पेज़ नहीं मिला…"
# posts/single.html
#
[readingTime]
one = "एक मिनट"
other = "{{ .Count }} मिनट"
[tableOfContents]
other = "अनुक्रमणिका"
[wordCount]
one = "एक शब्द"
other = "{{ .Count }} शब्द"
[lastModified]
other = "आखरी अपडेट"

View file

@ -1,39 +0,0 @@
# Translations for English
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traduzioni"
[postAvailable]
other = "Disponibile anche in"
# 404.html
#
[archives]
other = "Archivi"
[home]
other = "Home"
[notFound]
other = "Oops, pagina non trovata…"
# posts/single.html
#
[readingTime]
one = "Un minuto"
other = "{{ .Count }} minuti"
[tableOfContents]
other = "Contenuti"
[wordCount]
one = "Una parola"
other = "{{ .Count }} parole"
[lastModified]
other = "Ultimo aggiornamento"

View file

@ -1,39 +0,0 @@
# Translations for Japanese
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "翻訳"
[postAvailable]
other = "他の言語"
# 404.html
#
[archives]
other = "アーカイブ"
[home]
other = "ホームページ"
[notFound]
other = "あっ、ページが見つかりません……"
# Please add hasCJKLanguage = true under [languages.ja] for the below to behave correctly
# posts/single.html
#
[readingTime]
one = "一分"
other = "{{ .Count }}分"
[tableOfContents]
other = "目次"
[wordCount]
one = "一文字"
other = "{{ .Count }}文字"
[lastModified]
other = "最終更新"

View file

@ -1,39 +0,0 @@
# Translations for English
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traduzion"
[postAvailable]
other = "Disponibel anca in"
# 404.html
#
[archives]
other = "Archivi"
[home]
other = "Home"
[notFound]
other = "Oops, pagina minga trovada…"
# posts/single.html
#
[readingTime]
one = "On megnuu"
other = "{{ .Count }} megnuu"
[tableOfContents]
other = "Contegnuu"
[wordCount]
one = "Ona parolla"
other = "{{ .Count }} paroll"
[lastModified]
other = "Last update"

View file

@ -1,39 +0,0 @@
# Translations for മലയാളം [Malayalam]
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "വിവർത്തനങ്ങൾ"
[postAvailable]
other = "ഈ പോസ്റ്റ് ലഭ്യമായ മറ്റ് ഭാഷകൾ:"
# 404.html
#
[archives]
other = "ശേഖരം"
[home]
other = "പ്രധാന താൾ"
[notFound]
other = "ക്ഷമിക്കണം. താൾ ലഭ്യമല്ല. ദേയവയി വിലാസം പരിശോധിക്കുക അല്ലെങ്കിൽ അൽപ സമയത്തിനു ശേഷം വീണ്ടും പരിശ്രമിക്കുക."
# posts/single.html
#
[readingTime]
one = "ഒരു മിനിറ്റ്"
other = "{{ .Count }} മിനിറ്റുകൾ"
[tableOfContents]
other = "ഉള്ളടക്ക പട്ടിക"
[wordCount]
one = "ഒരു വാക്ക്"
other = "{{ .Count }} വാക്കുകൾ"
[lastModified]
other = "അവസാനമായി പുതുക്കിയത്"

View file

@ -1,39 +0,0 @@
# Translations for Portuguese
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traduções"
[postAvailable]
other = "Também disponível em"
# 404.html
#
[archives]
other = "Arquivo"
[home]
other = "Início"
[notFound]
other = "Oops, página não encontrada…"
# posts/single.html
#
[readingTime]
one = "Um minuto"
other = "{{ .Count }} minutos"
[tableOfContents]
other = "Índice"
[wordCount]
one = "Uma Palavra"
other = "{{ .Count }} Palavras"
[lastModified]
other = "Última actualização"

View file

@ -1,39 +0,0 @@
# Translations for Romanian
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Traduceri"
[postAvailable]
other = "Disponibil și în"
# 404.html
#
[archives]
other = "Arhive"
[home]
other = "Acasă"
[notFound]
other = "Ups, pagina nu a fost găsită…"
# posts/single.html
#
[readingTime]
one = "Un minut"
other = "{{ .Count }} de minute"
[tableOfContents]
other = "Cuprins"
[wordCount]
one = "Un cuvânt"
other = "{{ .Count }} de cuvinte"
[lastModified]
other = "Ultima modificare"

View file

@ -1,43 +0,0 @@
# Translations for Russian
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Переводы"
[postAvailable]
other = "Доступно на "
# 404.html
#
[archives]
other = "Архивы"
[home]
other = "Главная"
[notFound]
other = "Упс, страница не найдена…"
# posts/single.html
#
[readingTime]
one = "{{ .Count }} минута"
few = "{{ .Count }} минуты"
many = "{{ .Count }} минут"
other = "{{ .Count }} минут"
[tableOfContents]
other = "Содержимое"
[wordCount]
one = "{{ .Count }} слово"
few = "{{ .Count }} слова"
many = "{{ .Count }} слов"
other = "{{ .Count }} слов"
[lastModified]
other = "Последнее обновление"

View file

@ -1,39 +0,0 @@
# Translations for English
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Çeviriler"
[postAvailable]
other = "Ayrıca"
# 404.html
#
[archives]
other = "Arşiv"
[home]
other = "Ana Sayfa"
[notFound]
other = "Sayfa bulunamadı…"
# posts/single.html
#
[readingTime]
one = "Bir dakika"
other = "{{ .Count }} dakika"
[tableOfContents]
other = "İçindekiler"
[wordCount]
one = "One Kelime"
other = "{{ .Count }} Kelime"
[lastModified]
other = "Son güncelleme"

View file

@ -1,43 +0,0 @@
# Translations for Ukrainian
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "Переклади"
[postAvailable]
other = "Доступне на "
# 404.html
#
[archives]
other = "Архіви"
[home]
other = "Головна"
[notFound]
other = "Упс, сторінка не знайдена…"
# posts/single.html
#
[readingTime]
one = "{{ .Count }} хвилина"
few = "{{ .Count }} хвилини"
many = "{{ .Count }} хвилин"
other = "{{ .Count }} хвилин"
[tableOfContents]
other = "Вміст"
[wordCount]
one = "{{ .Count }} слово"
few = "{{ .Count }} слова"
many = "{{ .Count }} слів"
other = "{{ .Count }} слів"
[lastModified]
other = "Останнє оновлення"

View file

@ -1,39 +0,0 @@
# Translations for Chinese (China)
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "译文"
[postAvailable]
other = "其他语言"
# 404.html
#
[archives]
other = "档案"
[home]
other = "主页"
[notFound]
other = "噢,找不到页面……"
# Please add hasCJKLanguage = true under [languages.zh-cn] for the below to behave correctly
# posts/single.html
#
[readingTime]
one = "一分钟"
other = "{{ .Count }}分钟"
[tableOfContents]
other = "目录"
[wordCount]
one = "一字"
other = "{{ .Count }}字"
[lastModified]
other = "最后修改"

View file

@ -1,39 +0,0 @@
# Translations for Chinese (Hong Kong) [Cantonese]
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "譯文"
[postAvailable]
other = "其他語言"
# 404.html
#
[archives]
other = "貼文"
[home]
other = "主頁"
[notFound]
other = "哎呀,揾唔到添……"
# Please add hasCJKLanguage = true under [languages.zh-hk] for the below to behave correctly
# posts/single.html
#
[readingTime]
one = "一分鐘"
other = "{{ .Count }}分鐘"
[tableOfContents]
other = "目錄"
[wordCount]
one = "一粒字"
other = "{{ .Count }}字"
[lastModified]
other = "最後修改"

View file

@ -1,39 +0,0 @@
# Translations for Chinese (Taiwan)
# https://gohugo.io/content-management/multilingual/#translation-of-strings
# Generic
#
[translations]
other = "譯文"
[postAvailable]
other = "其他語言"
# 404.html
#
[archives]
other = "檔案"
[home]
other = "主頁"
[notFound]
other = "噢,找不到頁面……"
# Please add hasCJKLanguage = true under [languages.zh-tw] for the below to behave correctly
# posts/single.html
#
[readingTime]
one = "一分鐘"
other = "{{ .Count }}分鐘"
[tableOfContents]
other = "目錄"
[wordCount]
one = "一字"
other = "{{ .Count }}字"
[lastModified]
other = "最後修改"

View file

@ -1,18 +1 @@
{{- $isExternal := strings.HasPrefix .Destination "http" -}}
{{- $text := .Text -}}
{{/* It pains me that Hugo doesn't have a urls.IsValid method, and has no error catching to allow me to try urls.Parse and catch failures */}}
{{- if gt (len (strings.FindRE `^https?:\/\/[A-z0-9_-]*?[:]?[A-z0-9_-]*?[@]?[A-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$` .Text)) 0 -}}
{{- $url := urls.Parse $text -}}
{{- $text = strings.TrimPrefix "www." $url.Hostname -}}
{{- if lt (len $url.Path) 16 -}}
{{- $text = path.Join $text $url.Path -}}
{{- else -}}
{{- $parts := strings.Split $url.Path "/" -}}
{{- $last := index ($parts | last 1) 0 -}}
{{- if gt (len $last) 16 -}}
{{- $last = printf "%s…" (strings.Substr $last 0 16) -}}
{{- end -}}
{{- $text = path.Join $text "…" $last -}}
{{- end -}}
{{- end -}}
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isExternal }} target="_blank"{{ end }}>{{ $text }}</a>
{{ partial "rich-link.html" (dict "Text" .Text "Destination" .Destination "Title" .Title "Page" .Page) }}

View file

@ -1,17 +1,18 @@
{{ if not .Params.bookmarkOf}}
{{ errorf "BookmarkOf partial called when no bookmark of param set" }}
{{ end }}
{{- if not .Params.bookmarkOf -}}
{{ errorf "BookmarkOf partial called when no bookmark of param set" -}}
{{- end -}}
{{ $url := .Params.bookmarkOf }}
{{ $reference := dict }}
{{ range .Params.references }}
{{ if eq .url $url }}
{{ $reference = . }}
{{ end }}
{{ end }}
{{- $page := . -}}
{{- $url := .Params.bookmarkOf -}}
{{- $reference := dict -}}
{{- range .Params.references -}}
{{- if eq .url $url -}}
{{- $reference = . -}}
{{- end }}
{{- end -}}
💭 Thoughts on{{" "}}
{{- with $reference.name -}}
the article <a href="{{ $url }}" class="u-bookmark-of">{{ . }}</a>.
the article {{ partial "rich-link.html" (dict "Class" "u-bookmark-of" "Destination" $url "Text" . "Page" $page) }}.
{{- else -}}
<a href="{{ $url }}" class="u-bookmark-of">an article from {{ ($url | urls.Parse).Hostname }}</a>
{{ partial "rich-link.html" (dict "Class" "u-bookmark-of" "Destination" $url "Text" (printf "an article from %s" (($url | urls.Parse).Hostname)) "Page" $page) }}
{{- end }}

View file

@ -0,0 +1,29 @@
{{- $destination := .Destination -}}
{{- $title := .Title -}}
{{- $isExternal := strings.HasPrefix $destination "http" -}}
{{- $text := .Text -}}
{{/* It pains me that Hugo doesn't have a urls.IsValid method, and has no error catching to allow me to try urls.Parse and catch failures */}}
{{- if gt (len (strings.FindRE `^https?:\/\/[A-z0-9_-]*?[:]?[A-z0-9_-]*?[@]?[A-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$` .Text)) 0 -}}
{{- $url := urls.Parse $text -}}
{{- $text = strings.TrimPrefix "www." $url.Hostname -}}
{{- if lt (len $url.Path) 16 -}}
{{- $text = path.Join $text $url.Path -}}
{{- else -}}
{{- $parts := strings.Split $url.Path "/" -}}
{{- $last := index ($parts | last 1) 0 -}}
{{- if gt (len $last) 16 -}}
{{- $last = printf "%s…" (strings.Substr $last 0 16) -}}
{{- end -}}
{{- $text = path.Join $text "…" $last -}}
{{- end -}}
{{- end -}}
{{- $ref := dict -}}
{{- range $k, $refSpec := .Page.Params.references -}}
{{- if eq $refSpec.url $destination -}}
{{- $ref = $refSpec -}}
{{- if and (ne $title $ref.name) (ne $text $ref.name) -}}
{{- $title = printf "External article: %s" $ref.name -}}
{{- end -}}
{{- end -}}
{{- end -}}
<a href="{{ $destination | safeURL }}"{{ with .Class }} class="{{ . }}"{{ end }}{{ with $title }} title="{{ . }}"{{ end }}{{ if $isExternal }} target="_blank"{{ end }}{{ with $ref.rel }} rel="{{ . }}"{{ end }}>{{ $text }}</a>