Skip to content

Commit a9eff30

Browse files
committed
feat(docs): add HTML Escape plugin and nest glossary demo pages
1 parent 31fc019 commit a9eff30

20 files changed

Lines changed: 592 additions & 24 deletions

File tree

‎README.md‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ It documents BinaryNoir's open-source VitePress plugins, Vite plugins and comman
66

77
## Plugins demonstrated
88

9-
| Package | Role on this site |
10-
| ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
11-
| [`@binarynoir/vitepress-auto-sidebar`](https://github.com/binarynoir/vitepress-auto-sidebar) | Builds the sidebar from the folder tree |
12-
| [`@binarynoir/vitepress-auto-navbar`](https://github.com/binarynoir/vitepress-auto-navbar) | Builds the top navbar from the folder tree |
13-
| [`@binarynoir/vitepress-markdown-tags`](https://github.com/binarynoir/vitepress-markdown-tags) | Status badges and tagged-page lists |
14-
| [`@binarynoir/vitepress-reading-time-tag`](https://github.com/binarynoir/vitepress-reading-time-tag) | `[[readingTime]]` tip blocks |
15-
| [`@binarynoir/vitepress-downloads`](https://github.com/binarynoir/vitepress-downloads) | Downloadable files from a `downloads` folder (not yet wired in here) |
16-
| [`markdown-it-glossary`](https://github.com/binarynoir/markdown-it-glossary) | Hover definitions from `docs/reference/glossary.md` |
17-
| [`@binarynoir/vite-plugin-optimize-images`](https://github.com/binarynoir/vite-plugin-optimize-images) | Re-compresses images in the build output |
18-
| [`@binarynoir/vite-plugin-image-fallback`](https://github.com/binarynoir/vite-plugin-image-fallback) | Placeholder for missing images (one is missing on purpose) |
9+
| Package | Role on this site |
10+
| ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- |
11+
| [`@binarynoir/vitepress-auto-sidebar`](https://github.com/binarynoir/vitepress-auto-sidebar) | Builds the sidebar from the folder tree |
12+
| [`@binarynoir/vitepress-auto-navbar`](https://github.com/binarynoir/vitepress-auto-navbar) | Builds the top navbar from the folder tree |
13+
| [`@binarynoir/vitepress-markdown-tags`](https://github.com/binarynoir/vitepress-markdown-tags) | Status badges and tagged-page lists |
14+
| [`@binarynoir/vitepress-reading-time-tag`](https://github.com/binarynoir/vitepress-reading-time-tag) | `[[readingTime]]` tip blocks |
15+
| [`@binarynoir/vitepress-downloads`](https://github.com/binarynoir/vitepress-downloads) | Downloadable files from a `downloads` folder |
16+
| [`markdown-it-glossary`](https://github.com/binarynoir/markdown-it-glossary) | Hover definitions from `docs/reference/glossary.md` |
17+
| [`@binarynoir/vitepress-html-escape`](https://github.com/binarynoir/vitepress-html-escape) | Stray tags like `Array<string>` and `{{ }}` render as text |
18+
| [`@binarynoir/vite-plugin-optimize-images`](https://github.com/binarynoir/vite-plugin-optimize-images) | Re-compresses images in the build output |
19+
| [`@binarynoir/vite-plugin-image-fallback`](https://github.com/binarynoir/vite-plugin-image-fallback) | Placeholder for missing images (one is missing on purpose) |
1920

2021
## Develop
2122

‎docs/.vitepress/config.mts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { imageFallbackPlugin } from '@binarynoir/vite-plugin-image-fallback';
1010
import { optimizeImagesPlugin } from '@binarynoir/vite-plugin-optimize-images';
1111
import { downloadsMarkdown, downloadsVitePlugin } from '@binarynoir/vitepress-downloads';
1212
import { downloadsSrcExclude } from '@binarynoir/vitepress-downloads/vitepress';
13+
import { markdownHtmlEscape } from '@binarynoir/vitepress-html-escape';
1314

1415
// import.meta.dirname, not __dirname: VitePress configs are ESM.
1516
const docsRoot = path.resolve(import.meta.dirname, '..');
@@ -99,7 +100,7 @@ export default defineConfig({
99100
md.use(glossaryAbbr, {
100101
file: path.join(docsRoot, 'reference/glossary.md'),
101102
root: docsRoot,
102-
// Not the default `glossary.md`: docs/plugins/glossary.md is a documentation page, not a glossary.
103+
// Not the default `glossary.md`, so a page with that name is never read as a section glossary.
103104
scopedFile: 'section-glossary.md',
104105
});
105106
// @binarynoir/vitepress-reading-time-tag: [[readingTime]] becomes a tip block.
@@ -108,6 +109,9 @@ export default defineConfig({
108109
md.use(markdownTags);
109110
// @binarynoir/vitepress-downloads: links into a `downloads` or `files` folder become file downloads.
110111
md.use(downloadsMarkdown, downloadsOptions);
112+
// @binarynoir/vitepress-html-escape: stray tags like Array<string>, and {{ }} in prose,
113+
// render as text instead of breaking the Vue compile. It runs after every other rule.
114+
md.use(markdownHtmlEscape);
111115
},
112116
},
113117

‎docs/guide/how-this-site-works.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: How this site works
66

77
[[readingTime]]
88

9-
This site is plain VitePress 2 plus seven plugins. There is no hand-written navigation anywhere: add a Markdown file in the right folder and it shows up in the sidebar, the navbar, search and the sitemap.
9+
This site is plain VitePress 2 plus nine plugins. There is no hand-written navigation anywhere: add a Markdown file in the right folder and it shows up in the sidebar, the navbar, search and the sitemap.
1010

1111
## Folder layout
1212

@@ -34,7 +34,9 @@ docs/
3434
| Left sidebar | [Auto Sidebar](/plugins/auto-sidebar) | `themeConfig.sidebar` in `config.mts` |
3535
| Status badges | [Markdown Tags](/plugins/markdown-tags/) | `markdown.config`, plus the theme |
3636
| "Reading time" box | [Reading Time Tag](/plugins/reading-time-tag) | `markdown.config` |
37-
| Dotted-underline hovers | [Glossary Tooltips](/plugins/glossary) | `markdown.config` |
37+
| Dotted-underline hovers | [Glossary Tooltips](/plugins/glossary/) | `markdown.config` |
38+
| File download links | [Downloads](/plugins/downloads) | `markdown.config` and `vite.plugins` |
39+
| Stray `<tags>` shown as text | [HTML Escape](/plugins/html-escape/) | `markdown.config` |
3840
| Smaller images | [Optimize Images](/plugins/optimize-images) | `vite.plugins` |
3941
| Placeholder for a missing image | [Image Fallback](/plugins/image-fallback) | `vite.plugins` |
4042

‎docs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ npm install --save-dev \
9090
@binarynoir/vitepress-auto-navbar \
9191
@binarynoir/vitepress-markdown-tags \
9292
@binarynoir/vitepress-reading-time-tag \
93+
@binarynoir/vitepress-html-escape \
9394
markdown-it-glossary
9495
```
9596

‎docs/plugins/.nav‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎docs/plugins/.sidebar‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
index.md:Overview
44
auto-sidebar.md:Auto Sidebar
55
auto-navbar.md:Auto Navbar
6-
markdown-tags.md:Markdown Tags
6+
markdown-tags:Markdown Tags
77
reading-time-tag.md:Reading Time Tag
88
downloads.md:Downloads
9-
glossary.md:Glossary Tooltips
9+
glossary:Glossary Tooltips
10+
html-escape:HTML Escape
1011
optimize-images.md:Optimize Images
1112
image-fallback.md:Image Fallback

‎docs/plugins/glossary/.sidebar‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
index.md:Overview
2+
section-demo:Section Glossary Demo
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ docs/
107107
└─ team-b/index.md
108108
```
109109

110-
See it working on the [live section glossary demo](/plugins/glossary-demo/).
110+
See it working on the [live section glossary demo](/plugins/glossary/section-demo/).
111111

112112
To apply a section glossary to the whole site instead, set `glossary-scope: site` in that file's frontmatter. Section glossaries are found when the config loads, so adding or editing one needs a dev-server restart.
113113

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The glossary file holds this folder's terms; it is linked from the demo, not listed.
2+
-section-glossary.md

docs/plugins/glossary-demo/index.md renamed to docs/plugins/glossary/section-demo/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ title: Section Glossary Demo
44

55
# Section Glossary Demo
66

7-
A live example of [section glossaries](/plugins/glossary#section-glossaries). This folder has its own [glossary file](/plugins/glossary-demo/section-glossary), so its terms apply to this page and nowhere else on the site. Hover, click or tap a dotted word to read it.
7+
A live example of [section glossaries](/plugins/glossary/#section-glossaries). This folder has its own [glossary file](/plugins/glossary/section-demo/section-glossary), so its terms apply to this page and nowhere else on the site. Hover, click or tap a dotted word to read it.
88

99
- **Gizmo** exists only in this folder's glossary.
1010
- **CI** is defined by both this folder's glossary and the site's master glossary. The closer one wins, so you see the demo's definition here.
1111
- **CLI** is defined only by the master glossary, so it still works. A section glossary adds to the master; it doesn't replace it.
1212

13-
On the [plugin page](/plugins/glossary), CI shows the master's definition and Gizmo has no tooltip.
13+
On the [plugin page](/plugins/glossary/), CI shows the master's definition and Gizmo has no tooltip.

0 commit comments

Comments
 (0)