Skip to content

Commit 3db0552

Browse files
Introduce ReHype Plugin to remove .md from links
This uses ReHype to remove the `.md` file extension. Also set the content directory to a root path for WebStorm so you get proper path checking and validation when authoring.
1 parent 6843853 commit 3db0552

9 files changed

Lines changed: 132 additions & 5 deletions

File tree

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/webResources.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

astro.config.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-check
21
import { defineConfig, fontProviders } from "astro/config";
32
import starlight from "@astrojs/starlight";
43
import starlightLinksValidator from "starlight-links-validator";
@@ -10,10 +9,14 @@ import starlightHeadingBadges from "starlight-heading-badges";
109
import starlightLlmsTxt from "starlight-llms-txt";
1110
import rehypeAstroRelativeMarkdownLinks from "astro-rehype-relative-markdown-links";
1211
import opengraphImages from "astro-opengraph-images";
13-
import { duendeOpenGraphImage } from "./src/components/duende-og-image.js";
1412
import rehypeExternalLinks from "rehype-external-links";
1513
import * as fs from "node:fs";
1614

15+
// don't convert to path aliases, it doesn't work here
16+
// https://github.com/withastro/astro/issues/9782
17+
import { duendeOpenGraphImage } from "./src/plugins/duende-og-image.js";
18+
import removeMarkdownExtensions from "./src/plugins/remove-markdown-extensions.js";
19+
1720
// https://astro.build/config
1821
export default defineConfig({
1922
site: "https://docs.duendesoftware.com",
@@ -199,6 +202,7 @@ export default defineConfig({
199202
rel: ["noopener", "noreferrer"],
200203
},
201204
],
205+
[removeMarkdownExtensions, {}],
202206
],
203207
},
204208
});

package-lock.json

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dependencies": {
2626
"@astrojs/markdown-remark": "^6.3.1",
2727
"@astrojs/starlight": "^0.34.0",
28+
"@astrojs/ts-plugin": "^1.10.4",
2829
"@fontsource/roboto": "^5.2.5",
2930
"@pasqal-io/starlight-client-mermaid": "^0.1.0",
3031
"@resvg/resvg-js": "^2.6.2",

src/content/docs/identityserver/apis/aspnetcore/confirmation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ redirect_from:
1010
- /identityserver/v7/apis/aspnetcore/confirmation/
1111
---
1212

13-
IdentityServer can [bind tokens to clients](/identityserver/tokens/pop#proof-of-possession-styles) using either mTLS or DPoP, creating a `Proof-of-Possession` (PoP) access token. When one of these mechanisms is used, APIs that use those access tokens for authorization need to validate the binding between the client and token. This document describes how to perform such validation, depending on which mechanism was used to produce a PoP token.
13+
IdentityServer can [bind tokens to clients](/identityserver/tokens/pop.md#proof-of-possession-styles) using either mTLS or DPoP, creating a `Proof-of-Possession` (PoP) access token. When one of these mechanisms is used, APIs that use those access tokens for authorization need to validate the binding between the client and token. This document describes how to perform such validation, depending on which mechanism was used to produce a PoP token.
1414

1515
### Validating mTLS
1616

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { visit } from "unist-util-visit";
2+
import type { Node, Parent } from "unist";
3+
4+
interface Element extends Parent {
5+
type: "element";
6+
tagName: string;
7+
properties: {
8+
[key: string]: unknown;
9+
};
10+
content: Node;
11+
children: Node[];
12+
}
13+
14+
export default function removeMarkdownExtensions(): (tree: Node) => void {
15+
return (tree: Node) => {
16+
visit(tree, "element", (node: Element) => {
17+
if (
18+
node.tagName === "a" &&
19+
node.properties &&
20+
typeof node.properties.href === "string"
21+
) {
22+
const markdownExtensionRegex = /\.md(#.*)?$/;
23+
if (markdownExtensionRegex.test(node.properties.href)) {
24+
let date = new Date().toLocaleTimeString("en-US", { hour12: false });
25+
console.log(
26+
`\x1b[90m${date}\x1b[0m \x1b[95m[🔥 *.md]\x1b[0m ${node.properties.href}`,
27+
);
28+
29+
node.properties.href = node.properties.href.replace(
30+
markdownExtensionRegex,
31+
"$1",
32+
);
33+
}
34+
}
35+
});
36+
};
37+
}

tsconfig.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33
"include": [".astro/types.d.ts", "**/*"],
44
"exclude": ["dist"],
55
"compilerOptions": {
6+
"verbatimModuleSyntax": true,
67
"baseUrl": ".",
78
"paths": {
8-
"~/*": ["src/*"]
9-
}
9+
"~/*": ["src/*"],
10+
"@plugins/*": ["src/plugins/*"],
11+
"@components/*": ["src/components/*"]
12+
},
13+
"plugins": [
14+
{
15+
"name": "@astrojs/ts-plugin"
16+
}
17+
]
1018
}
1119
}

0 commit comments

Comments
 (0)