reorganises images in capsule, symlinks to website

This commit is contained in:
2026-04-13 09:40:10 +01:00
parent 1a64bce2fb
commit ef451a063b
11 changed files with 67 additions and 23 deletions
+1
View File
@@ -0,0 +1 @@
../../../capsule/content/images/
+5
View File
@@ -31,6 +31,11 @@ const GemtextHTMLRenderer: Gemtext.Renderer<string> = {
return `<p>${htmlEscape(content)}</p>`
},
link: function (url: string, alt: string): string {
url = url.replaceAll(/^\/images\//g, '/images/capsule/');
const imgExtensions: (string | undefined)[] = ['webp', 'png', 'svg', 'gif', 'jpg', 'jpeg', 'apng']
if (imgExtensions.includes(url.split('.').at(-1)?.toLowerCase())) {
return `<img src="${url}" alt="${alt}" />`;
}
return `<p>=> <a href="${url}">${alt}</a></p>`;
},
preformatted: function (content: string[], alt: string): string {