@zabaca/lattice 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js
CHANGED
|
@@ -437,7 +437,8 @@ var SITE_TEMPLATE_FILES = [
|
|
|
437
437
|
"src/content.config.ts",
|
|
438
438
|
"src/collections/authors.ts",
|
|
439
439
|
"src/collections/documents.ts",
|
|
440
|
-
"src/collections/tags.ts"
|
|
440
|
+
"src/collections/tags.ts",
|
|
441
|
+
"src/plugins/rehype-strip-md-extension.ts"
|
|
441
442
|
];
|
|
442
443
|
|
|
443
444
|
class InitCommand extends CommandRunner2 {
|
|
@@ -522,6 +523,9 @@ OBSIDIAN_VAULT_DIR=docs
|
|
|
522
523
|
await fs.mkdir(path.join(latticeHome, "src", "collections"), {
|
|
523
524
|
recursive: true
|
|
524
525
|
});
|
|
526
|
+
await fs.mkdir(path.join(latticeHome, "src", "plugins"), {
|
|
527
|
+
recursive: true
|
|
528
|
+
});
|
|
525
529
|
let copied = 0;
|
|
526
530
|
let skipped = 0;
|
|
527
531
|
for (const file of SITE_TEMPLATE_FILES) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { defineConfig } from 'astro/config';
|
|
2
2
|
import { astroSpaceship } from 'astro-spaceship';
|
|
3
|
+
import rehypeStripMdExtension from './src/plugins/rehype-strip-md-extension';
|
|
3
4
|
|
|
4
5
|
import websiteConfig from 'astro-spaceship/config';
|
|
5
6
|
|
|
6
7
|
export default defineConfig({
|
|
8
|
+
markdown: {
|
|
9
|
+
rehypePlugins: [rehypeStripMdExtension],
|
|
10
|
+
},
|
|
7
11
|
integrations: [
|
|
8
12
|
astroSpaceship(websiteConfig)
|
|
9
13
|
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
import type { Root, Element } from 'hast';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Rehype plugin that strips .md extensions from relative links.
|
|
6
|
+
* This allows standard markdown links like [text](./file.md) to work
|
|
7
|
+
* correctly in Astro where routes don't include the .md extension.
|
|
8
|
+
*/
|
|
9
|
+
export default function rehypeStripMdExtension() {
|
|
10
|
+
return (tree: Root) => {
|
|
11
|
+
visit(tree, 'element', (node: Element) => {
|
|
12
|
+
if (
|
|
13
|
+
node.tagName === 'a' &&
|
|
14
|
+
typeof node.properties?.href === 'string'
|
|
15
|
+
) {
|
|
16
|
+
const href = node.properties.href;
|
|
17
|
+
// Only process relative links ending in .md
|
|
18
|
+
if (
|
|
19
|
+
!href.startsWith('http://') &&
|
|
20
|
+
!href.startsWith('https://') &&
|
|
21
|
+
!href.startsWith('//') &&
|
|
22
|
+
href.endsWith('.md')
|
|
23
|
+
) {
|
|
24
|
+
node.properties.href = href.slice(0, -3);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|