Skip to content

Commit 3f23cb4

Browse files
authored
Merge pull request #447 from axivo/docs/website-update
docs: website update
2 parents 9e8e61d + 9c9366b commit 3f23cb4

File tree

13 files changed

+213
-7
lines changed

13 files changed

+213
-7
lines changed

claude/assets/css/custom.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* Plyr video player */
2+
.content .plyr {
3+
margin-inline: auto;
4+
margin-block: calc(var(--hx-spacing) * 6);
5+
border-radius: var(--hx-radius-md);
6+
overflow: hidden;
7+
}

claude/content/reflections/_content.gotmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@
137137
{{ $cleanContent = replaceRE `- [*][*]UUID:[*][*][^\n]+\n` "" $cleanContent }}
138138
{{ $cleanContent = replaceRE `^\n+` "\n" $cleanContent }}
139139

140-
{{/* Rewrite relative image paths to absolute */}}
141-
{{ $imageBasePath := printf "/reflections/diary/%s/%s/images/" $year $month }}
142-
{{ $cleanContent = replaceRE `[(]images/` (printf "(%s" $imageBasePath) $cleanContent }}
143-
{{ $cleanContent = replaceRE `[[]images/` (printf "[%s" $imageBasePath) $cleanContent }}
140+
{{/* Rewrite relative media paths to absolute */}}
141+
{{ $mediaPath := printf "/reflections/diary/%s/%s/media/" $year $month }}
142+
{{ $cleanContent = replaceRE `[(]media/` (printf "(%s" $mediaPath) $cleanContent }}
143+
{{ $cleanContent = replaceRE `[[]media/` (printf "[%s" $mediaPath) $cleanContent }}
144+
{{ $cleanContent = replaceRE `src="media/` (printf "src=\"%s" $mediaPath) $cleanContent }}
144145

145146
{{/* Rewrite relative .md links to day section paths */}}
146147
{{/* Same month: (DD.md) -> (/reflections/YYYY/MM/DD/) */}}

claude/hugo.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ module:
5454
imports:
5555
- path: github.com/axivo/website/global
5656
- path: github.com/imfing/hextra
57+
outputs:
58+
page: [html, markdown]
59+
section: [html, markdown, rss]
5760
params:
5861
comments:
5962
giscus:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{/* Core scripts (theme, menu, tabs, etc.) */}}
2+
{{- partial "scripts/core.html" . -}}
3+
4+
{{/* Search */}}
5+
{{- partial "scripts/search.html" . -}}
6+
7+
{{/* Mermaid */}}
8+
{{- if (.Store.Get "hasMermaid") -}}
9+
{{- partial "scripts/mermaid.html" . -}}
10+
{{- end -}}
11+
12+
{{/* Asciinema */}}
13+
{{- if (.Store.Get "hasAsciinema") -}}
14+
{{- partial "scripts/asciinema.html" . -}}
15+
{{- end -}}
16+
17+
{{/* Medium Zoom */}}
18+
{{- if (.Store.Get "hasImageZoom") -}}
19+
{{- partial "scripts/medium-zoom.html" . -}}
20+
{{- end -}}
21+
22+
{{/* Plyr */}}
23+
{{- if (.Store.Get "hasPlyr") -}}
24+
{{- partial "scripts/plyr.html" . -}}
25+
{{- end -}}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{{- /* Plyr */ -}}
2+
3+
{{- $plyrBase := "" -}}
4+
{{- $useDefaultCdn := true -}}
5+
{{- with site.Params.plyr.base -}}
6+
{{- $plyrBase = . -}}
7+
{{- $useDefaultCdn = false -}}
8+
{{- end -}}
9+
10+
{{- $plyrJsAsset := "" -}}
11+
{{- with site.Params.plyr.js -}}
12+
{{- $plyrJsAsset = . -}}
13+
{{- end -}}
14+
15+
{{- $plyrCssAsset := "" -}}
16+
{{- with site.Params.plyr.css -}}
17+
{{- $plyrCssAsset = . -}}
18+
{{- end -}}
19+
20+
{{- /* If only js/css is set without base, use local asset loading */ -}}
21+
{{- if and $useDefaultCdn (or (ne $plyrJsAsset "") (ne $plyrCssAsset "")) -}}
22+
{{- $useDefaultCdn = false -}}
23+
{{- end -}}
24+
25+
{{- /* Set default CDN base if needed */ -}}
26+
{{- if $useDefaultCdn -}}
27+
{{- $plyrBase = "https://cdn.jsdelivr.net/npm/plyr@latest/dist" -}}
28+
{{- end -}}
29+
30+
{{- $isRemoteBase := or (strings.HasPrefix $plyrBase "http://") (strings.HasPrefix $plyrBase "https://") -}}
31+
{{- $minSuffix := cond hugo.IsProduction ".min" "" -}}
32+
33+
{{- /* CSS retrieval */ -}}
34+
{{- if $isRemoteBase -}}
35+
{{- $cssPath := cond (ne $plyrCssAsset "") $plyrCssAsset "plyr.css" -}}
36+
{{- $plyrCssUrl := printf "%s/%s" $plyrBase $cssPath -}}
37+
{{- with try (resources.GetRemote $plyrCssUrl) -}}
38+
{{- with .Err -}}
39+
{{- errorf "Could not retrieve Plyr css file from %s. Reason: %s." $plyrCssUrl . -}}
40+
{{- else with .Value -}}
41+
{{- with resources.Copy "css/plyr.css" . -}}
42+
{{- $plyrCss := . | fingerprint -}}
43+
<link rel="stylesheet" href="{{ $plyrCss.RelPermalink }}" integrity="{{ $plyrCss.Data.Integrity }}" crossorigin="anonymous" />
44+
{{- end -}}
45+
{{- end -}}
46+
{{- end -}}
47+
{{- else if $plyrCssAsset -}}
48+
{{- with resources.Get $plyrCssAsset -}}
49+
{{- $plyrCss := . | fingerprint -}}
50+
<link rel="stylesheet" href="{{ $plyrCss.RelPermalink }}" integrity="{{ $plyrCss.Data.Integrity }}" crossorigin="anonymous" />
51+
{{- else -}}
52+
{{- errorf "Plyr css asset not found at %q" $plyrCssAsset -}}
53+
{{- end -}}
54+
{{- end -}}
55+
56+
{{- /* JS retrieval */ -}}
57+
{{- if $isRemoteBase -}}
58+
{{- $jsPath := cond (ne $plyrJsAsset "") $plyrJsAsset (printf "plyr.polyfilled%s.js" $minSuffix) -}}
59+
{{- $plyrJsUrl := printf "%s/%s" $plyrBase $jsPath -}}
60+
{{- with try (resources.GetRemote $plyrJsUrl) -}}
61+
{{- with .Err -}}
62+
{{- errorf "Could not retrieve Plyr js file from %s. Reason: %s." $plyrJsUrl . -}}
63+
{{- else with .Value -}}
64+
{{- with resources.Copy (printf "js/plyr.polyfilled%s.js" $minSuffix) . -}}
65+
{{- $plyrJs := . | fingerprint -}}
66+
<script defer src="{{ $plyrJs.RelPermalink }}" integrity="{{ $plyrJs.Data.Integrity }}" crossorigin="anonymous"></script>
67+
{{- end -}}
68+
{{- end -}}
69+
{{- end -}}
70+
{{- else if $plyrJsAsset -}}
71+
{{- with resources.Get $plyrJsAsset -}}
72+
{{- $plyrJs := . | fingerprint -}}
73+
<script defer src="{{ $plyrJs.RelPermalink }}" integrity="{{ $plyrJs.Data.Integrity }}" crossorigin="anonymous"></script>
74+
{{- else -}}
75+
{{- errorf "Plyr js asset not found at %q" $plyrJsAsset -}}
76+
{{- end -}}
77+
{{- end -}}
78+
79+
<script>
80+
document.addEventListener("DOMContentLoaded", () => {
81+
document.querySelectorAll(".content video, .content audio, .content [data-plyr-provider]").forEach((el) => {
82+
new Plyr(el);
83+
});
84+
});
85+
</script>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- /* Plyr partial: renders HTML5 audio, HTML5 video, Vimeo, or YouTube */ -}}
2+
<div>
3+
{{- if eq .type "audio" -}}
4+
<audio controls
5+
{{- if eq (printf "%v" .autoplay) "true" }} autoplay{{ end -}}
6+
{{- if eq (printf "%v" .muted) "true" }} muted{{ end -}}
7+
{{- if eq (printf "%v" .loop) "true" }} loop{{ end -}}>
8+
<source src="{{ .src }}" />
9+
</audio>
10+
{{- else if eq .provider "vimeo" -}}
11+
<div data-plyr-provider="vimeo" data-plyr-embed-id="{{ .src }}"></div>
12+
{{- else if eq .provider "youtube" -}}
13+
<div data-plyr-provider="youtube" data-plyr-embed-id="{{ .src }}"></div>
14+
{{- else -}}
15+
<video playsinline controls
16+
{{- with .poster }} data-poster="{{ . }}"{{ end -}}
17+
{{- if eq (printf "%v" .autoplay) "true" }} autoplay{{ end -}}
18+
{{- if eq (printf "%v" .muted) "true" }} muted{{ end -}}
19+
{{- if eq (printf "%v" .loop) "true" }} loop{{ end -}}>
20+
<source src="{{ .src }}" type="video/mp4" />
21+
</video>
22+
{{- end -}}
23+
</div>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{{- /*
2+
A shortcode to embed media using the Plyr player.
3+
4+
Supports HTML5 video, HTML5 audio, YouTube, and Vimeo.
5+
6+
@param {string} src The source URL, path, or embed ID.
7+
@param {string} [provider] The media provider: "youtube", "vimeo", or omit for HTML5.
8+
@param {string} [type=video] The media type: "video" or "audio".
9+
@param {bool} [autoplay=false] Whether to autoplay.
10+
@param {bool} [muted=false] Whether to mute.
11+
@param {bool} [loop=false] Whether to loop.
12+
@param {string} [poster] The poster image URL (HTML5 video only).
13+
14+
@example {{< media src="media/example.mp4" >}}
15+
@example {{< media src="bTqVqk7FSmY" provider="youtube" >}}
16+
@example {{< media src="76979871" provider="vimeo" >}}
17+
@example {{< media src="media/example.mp3" type="audio" >}}
18+
*/ -}}
19+
{{- $src := .Get "src" | default (.Get 0) -}}
20+
{{- $provider := .Get "provider" | default "" -}}
21+
{{- $type := .Get "type" | default "video" -}}
22+
{{- $autoplay := .Get "autoplay" | default false -}}
23+
{{- $muted := .Get "muted" | default false -}}
24+
{{- $loop := .Get "loop" | default false -}}
25+
{{- $poster := .Get "poster" | default "" -}}
26+
27+
{{- if not $src -}}
28+
{{- errorf "Media 'src' must be supplied" -}}
29+
{{- end -}}
30+
31+
{{/* Resolve local file path for HTML5 media */}}
32+
{{- if not $provider -}}
33+
{{- $isLocal := not (urls.Parse $src).Scheme -}}
34+
{{- if $isLocal -}}
35+
{{- if hasPrefix $src "/" -}}
36+
{{- $src = relURL (strings.TrimPrefix "/" $src) -}}
37+
{{- else -}}
38+
{{- $src = relURL $src -}}
39+
{{- end -}}
40+
{{- end -}}
41+
{{- end -}}
42+
43+
{{/* Mark page as using Plyr */}}
44+
{{- .Page.Store.Set "hasPlyr" true -}}
45+
46+
{{- partial "shortcodes/media" (dict
47+
"src" $src
48+
"provider" $provider
49+
"type" $type
50+
"autoplay" $autoplay
51+
"muted" $muted
52+
"loop" $loop
53+
"poster" $poster
54+
) -}}

docs/hugo.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ module:
2222
imports:
2323
- path: github.com/axivo/website/global
2424
- path: github.com/imfing/hextra
25+
outputs:
26+
page: [html, markdown]
27+
section: [html, markdown, rss]
2528
params:
2629
description: Imagine. Create.
2730
editURL:

global/hugo.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ markup:
2121
noClasses: false
2222
outputs:
2323
home: [html]
24-
page: [html, markdown]
25-
section: [html, markdown, rss]
2624
params:
2725
blog:
2826
list:

0 commit comments

Comments
 (0)