Skip to content

Commit

Permalink
anchor href fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dbushell committed Oct 23, 2024
1 parent a36e9ef commit 1e84279
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/data
Submodule data updated from 19edb7 to 74c42c
10 changes: 10 additions & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -79,6 +80,15 @@ export const readProps = async (srcPath: string): Promise<Props> => {
"/";
}

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));
Expand Down
2 changes: 1 addition & 1 deletion src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) {
Expand Down

0 comments on commit 1e84279

Please sign in to comment.