Skip to content

Commit defb836

Browse files
committed
feat(docs): add vitepress-downloads plugin and bump dependencies
1 parent 3281939 commit defb836

4 files changed

Lines changed: 146 additions & 109 deletions

File tree

‎docs/.vitepress/config.mts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@ import { generateNav } from '@binarynoir/vitepress-auto-navbar';
88
import { generateSidebar } from '@binarynoir/vitepress-auto-sidebar';
99
import { imageFallbackPlugin } from '@binarynoir/vite-plugin-image-fallback';
1010
import { optimizeImagesPlugin } from '@binarynoir/vite-plugin-optimize-images';
11+
import { downloadsMarkdown, downloadsVitePlugin } from '@binarynoir/vitepress-downloads';
12+
import { downloadsSrcExclude } from '@binarynoir/vitepress-downloads/vitepress';
1113

1214
// import.meta.dirname, not __dirname: VitePress configs are ESM.
1315
const docsRoot = path.resolve(import.meta.dirname, '..');
1416

1517
const SITE_URL = 'https://binarynoir.github.io';
1618

19+
// @binarynoir/vitepress-downloads: the same options go to all three pieces below.
20+
const downloadsOptions = { folders: ['downloads', 'files'] };
21+
1722
export default defineConfig({
1823
title: 'BinaryNoir',
1924
description: 'Open-source tools and VitePress plugins by BinaryNoir, with live demos.',
2025
lang: 'en-US',
2126
cleanUrls: true,
2227
lastUpdated: true,
2328

24-
// Downloadable files are published as-is, never built as pages.
25-
srcExclude: ['**/downloads/**'],
29+
// Files in a `downloads` or `files` folder are published as-is, never built as pages.
30+
srcExclude: downloadsSrcExclude(downloadsOptions),
2631

2732
sitemap: { hostname: SITE_URL },
2833

@@ -93,6 +98,8 @@ export default defineConfig({
9398
md.use(readingTimeTag);
9499
// @binarynoir/vitepress-markdown-tags: ((tag|Done|green)) becomes a badge.
95100
md.use(markdownTags);
101+
// @binarynoir/vitepress-downloads: links into a `downloads` or `files` folder become file downloads.
102+
md.use(downloadsMarkdown, downloadsOptions);
96103
},
97104
},
98105

@@ -115,6 +122,8 @@ export default defineConfig({
115122
optimizeImagesPlugin({ verbose: true }),
116123
// Keeps `tagged: true` pages current while running `vitepress dev`.
117124
taggedPagesVitePlugin(),
125+
// Publishes the files in each `downloads` or `files` folder at their page-relative URL.
126+
downloadsVitePlugin(downloadsOptions),
118127
],
119128
},
120129
});

‎docs/plugins/downloads.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The file is published at `/tools/ai/downloads/check-access.sql`, and the link do
2424

2525
## Try it
2626

27-
This page has its own `downloads` folder: `sample.sql` and `sample.md`.
27+
This page has its own `downloads` folder: [sample.sql](./downloads/sample.sql) and [sample.md](./downloads/sample.md).
2828

2929
## Install
3030

0 commit comments

Comments
 (0)