From 1e842799ccc56a1afc4d966c100012d21c92d219 Mon Sep 17 00:00:00 2001 From: David Bushell Date: Wed, 23 Oct 2024 15:16:50 +0100 Subject: [PATCH] anchor href fix --- deno.jsonc | 6 +++--- src/data | 2 +- src/data.ts | 10 ++++++++++ src/markdown.ts | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 9321c5e..57c7418 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -7,9 +7,9 @@ }, "imports": { "@dbushell/carriageway": "jsr:@dbushell/carriageway@^1.1.0", - "@dbushell/hmmarkdown": "jsr:@dbushell/hmmarkdown@^0.14.0", - "@dbushell/hyperless": "jsr:@dbushell/hyperless@^0.26.0", - "@dbushell/hyperserve": "jsr:@dbushell/hyperserve@^0.18.0", + "@dbushell/hmmarkdown": "jsr:@dbushell/hmmarkdown@^0.15.0", + "@dbushell/hyperless": "jsr:@dbushell/hyperless@^0.27.0", + "@dbushell/hyperserve": "jsr:@dbushell/hyperserve@^0.19.0", "@shikijs/transformers": "npm:@shikijs/transformers@^1.22.0", "@src/": "./src/", "@std/async": "jsr:@std/async@^1.0.6", diff --git a/src/data b/src/data index 19edb71..74c42cf 160000 --- a/src/data +++ b/src/data @@ -1 +1 @@ -Subproject commit 19edb717fddfaaa408ec6f919f87eaab86e7cc1e +Subproject commit 74c42cf2cd5797b2b42de15dc9b206d097d8bbf7 diff --git a/src/data.ts b/src/data.ts index bee84f4..3cff80e 100644 --- a/src/data.ts +++ b/src/data.ts @@ -10,6 +10,7 @@ import type { FrontProps, NoteProps, Props } from "./types.ts"; const dataPath = path.resolve(Deno.cwd(), "src/data"); const cachePath = path.join(Deno.cwd(), ".cache"); +const snapshotPath = path.join(Deno.cwd(), ".snapshot"); const DEV = Deno.args.includes("--dev"); @@ -79,6 +80,15 @@ export const readProps = async (srcPath: string): Promise => { "/"; } + if (Deno.args.includes("--snapshot")) { + let snap = `${props.href.slice(1, -1).replaceAll("/", "-")}.html`; + snap = path.join(snapshotPath, snap); + await Deno.writeTextFile( + snap, + props.body.replace(/syntax-\d+/g, ""), + ); + } + // Save cached props if (DEV) { await Deno.writeTextFile(pathname, JSON.stringify(props)); diff --git a/src/markdown.ts b/src/markdown.ts index 9fae8de..ae72d7e 100644 --- a/src/markdown.ts +++ b/src/markdown.ts @@ -56,7 +56,7 @@ const anchorNode = (a: Node) => { ? new URL(href, "https://dbushell.com") : new URL(href); const excludePaths = ["/tip/", "/mastodon/"]; - a.attributes.set("href,", href[0] === "#" ? url.hash : url.href); + a.attributes.set("href", href[0] === "#" ? url.hash : url.href); if ( url.hostname !== "dbushell.com" || excludePaths.includes(url.pathname) ) {