Skip to content

Commit 21262ce

Browse files
committed
docs: document titleCase option and upgrade auto-sidebar / auto-navbar
1 parent 0fa4fe8 commit 21262ce

7 files changed

Lines changed: 33 additions & 12 deletions

File tree

‎docs/plugins/auto-navbar.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Each top-level folder becomes a navbar entry: a dropdown if it has several pages
5656
| `flattenSinglePage` | `true` | A folder with one entry becomes a plain link. |
5757
| `activeMatch` | `true` | Keep items highlighted on every page beneath them. |
5858
| `titleReplacements` | `{}` | Words to replace in titles made from file and folder names. |
59+
| `titleCase` | `true` | Title-case titles made from file and folder names. |
5960
| `stripTags` | `true` | Remove Markdown Tags syntax (`((tag\|draft))`) from titles. |
6061
| `transformTitle` | none | A function that gets every title before truncation. |
6162
| `verbose` | `false` | Log each folder as it is processed. |
@@ -68,7 +69,9 @@ A folder's landing page is its `index.md`, or its `README.md`. VitePress serves
6869

6970
This site passes the same title options to both menus. See them working in the [Sidebar Titles Demo](/plugins/auto-sidebar/titles-demo/), and in this site's [config](https://github.com/binarynoir/binarynoir.github.io/blob/main/docs/.vitepress/config.mts).
7071

71-
A title made from a file or folder name is formatted: `getting-started.md` becomes "Getting Started". Only first letters are capitalised, so use `titleReplacements` for words with other casing. Keys match whole words, ignoring case:
72+
A title made from a file or folder name is formatted: `getting-started.md` becomes "Getting Started". It is title-cased, so articles, short conjunctions and prepositions (`a`, `the`, `and`, `of`, `to`, …) stay lowercase unless they are the first or last word: `guide-to-the-cli.md` becomes "Guide to the Cli". Set `titleCase: false` to capitalise every word instead.
73+
74+
Only first letters change case, so use `titleReplacements` for words with other casing. Keys match whole words, ignoring case:
7275

7376
```ts
7477
generateNav(docsRoot, {

‎docs/plugins/auto-sidebar/index.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Files need their `.md` extension in these lines. A `.exclude` file removes draft
7272
| `collapsed` | `false` | Initial collapsed state for section headers. |
7373
| `flattenSinglePage` | `true` | A folder with one page becomes a plain link instead of its own group. |
7474
| `titleReplacements` | `{}` | Words to replace in titles made from file and folder names. |
75+
| `titleCase` | `true` | Title-case titles made from file and folder names. |
7576
| `stripTags` | `true` | Remove Markdown Tags syntax (`((tag\|draft))`) from titles. |
7677
| `transformTitle` | none | A function that gets every title before truncation. |
7778
| `groupTitleFromIndex` | `false` | Label a folder's group with its landing page's title. |
@@ -83,7 +84,9 @@ Files need their `.md` extension in these lines. A `.exclude` file removes draft
8384
The [Sidebar Titles Demo](./titles-demo/) folder, in the sidebar under **Auto Sidebar**, uses each option below on this site's real sidebar.
8485
:::
8586

86-
A title made from a file or folder name is formatted: `getting-started.md` becomes "Getting Started". Only first letters are capitalised, so use `titleReplacements` for words with other casing. Keys match whole words, ignoring case:
87+
A title made from a file or folder name is formatted: `getting-started.md` becomes "Getting Started". It is title-cased, so articles, short conjunctions and prepositions (`a`, `the`, `and`, `of`, `to`, …) stay lowercase unless they are the first or last word: `guide-to-the-cli.md` becomes "Guide to the Cli". Set `titleCase: false` to capitalise every word instead.
88+
89+
Only first letters change case, so use `titleReplacements` for words with other casing. Keys match whole words, ignoring case:
8790

8891
```ts
8992
generateSidebar(docsRoot, {

‎docs/plugins/auto-sidebar/titles-demo/.sidebar‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# after a space.
44
index.md
55
github-actions-setup.md
6+
guide-to-the-cli.md
67
draft-notes.md
78
example-renamed-page.md
89
https://vitepress.dev: 'VitePress docs'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This page has no `title` frontmatter and no `# Heading`, so [Auto Sidebar](/plugins/auto-sidebar/) titles it from its file name, `guide-to-the-cli.md`.
2+
3+
## With `titleCase`
4+
5+
`titleCase` is on by default. Articles, short conjunctions and prepositions such as `a`, `the`, `and`, `of` and `to` stay lowercase unless they are the first or last word, so the sidebar shows **Guide to the Cli**.
6+
7+
## Without `titleCase`
8+
9+
With `titleCase: false`, every word is capitalised: "Guide To The Cli".
10+
11+
Only first letters change case, so "Cli" stays "Cli". Add `{ cli: 'CLI' }` to `titleReplacements` to write it as "CLI". Titles an author wrote are never re-cased.
12+
13+
[Back to the demo](./)

‎docs/plugins/auto-sidebar/titles-demo/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ generateSidebar(docsRoot, {
2323
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2424
| **Sidebar Titles Demo**, the group label | This page's `title`, with `groupTitleFromIndex`. The folder is `titles-demo`, and its parent `.sidebar` doesn't name it, so without the option the label would be "Titles Demo". |
2525
| [GitHub Actions Setup](./github-actions-setup) | The file name `github-actions-setup.md`, since the page has no title or `# Heading`. `titleReplacements` turns "Github" into "GitHub". |
26+
| [Guide to the Cli](./guide-to-the-cli) | The file name `guide-to-the-cli.md`. `titleCase` (on by default) keeps "to" and "the" lowercase mid-title. |
2627
| [Draft notes](./draft-notes) | The page's heading, `# Draft notes ((tag\|draft\|orange))`. `stripTags` (on by default) removes the tag from the sidebar, and the page still shows the badge. |
2728
| [Renamed page](./example-renamed-page) | The page's heading, `# Example: Renamed page`. `transformTitle` removes the "Example: " prefix from page titles. |
2829
| [VitePress docs](https://vitepress.dev) | The `.sidebar` line `https://vitepress.dev: 'VitePress docs'`. A single-quoted title after a space works, and so does a double-quoted one. A line that can't be parsed logs a warning naming the file and line instead. |

‎package-lock.json‎

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

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"devDependencies": {
2525
"@binarynoir/vite-plugin-image-fallback": "^0.4.0",
2626
"@binarynoir/vite-plugin-optimize-images": "^0.1.9",
27-
"@binarynoir/vitepress-auto-navbar": "^0.4.1",
28-
"@binarynoir/vitepress-auto-sidebar": "^0.6.1",
27+
"@binarynoir/vitepress-auto-navbar": "^0.5.0",
28+
"@binarynoir/vitepress-auto-sidebar": "^0.7.0",
2929
"@binarynoir/vitepress-broken-links": "^0.1.2",
3030
"@binarynoir/vitepress-downloads": "^0.1.3",
3131
"@binarynoir/vitepress-exclude": "^0.1.1",

0 commit comments

Comments
 (0)