Skip to content

Commit 8186eec

Browse files
committed
feat(docs): sidebar follows blog scopes
- config: Auto Sidebar blog option on; Auto Sidebar 0.11.0 and Auto Navbar 0.8.2 - docs: Auto Sidebar Grouping and Blogs sections, blog page notes, scopes demo sidebars sorted by date
1 parent 300d088 commit 8186eec

7 files changed

Lines changed: 41 additions & 14 deletions

File tree

‎docs/.vitepress/config.mts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ export default defineConfig({
131131
excludeFrontmatter,
132132
...menuTitleOptions,
133133
groupTitleFromIndex: true,
134+
// Blog folders list posts as their blog pages do: pinned, then newest first, and the main
135+
// blog's folder also lists the `scope: site` posts from the section blogs inside it.
136+
blog: true,
134137
// Groups start closed, so @binarynoir/vitepress-sidebar-accordion (in the theme) has a caret to toggle.
135138
collapsed: true,
136139
}),

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ A line that starts with a dot is a setting for the folder, not an entry. Every s
7272
| `.sort: key [asc\|desc], …` | Order the entries this file doesn't list by `key`. Default: `name`. |
7373
| `.limit: n` | Show at most `n` of the entries this file doesn't list, after sorting. `0` for no limit. |
7474
| `.more: Text` | When `.limit` left entries out, end with a link to the landing page titled `Text`. |
75+
| `.group: year\|month\|blog` | Put the entries this file doesn't list in groups. See [Grouping](#grouping). |
7576
| `.hide` | Hide this folder's own link, but keep showing its children. |
7677
| `.hideall` or `.hide-all` | Leave this folder and everything under it out of the sidebar. |
7778

@@ -109,6 +110,27 @@ A folder with hundreds of pages makes a sidebar too long to use, and VitePress s
109110
- `.more: Older posts` ends the list with a link to the folder's landing page, but only when entries were left out. The blog doesn't need one: its landing page is already listed as "All posts".
110111
- `.limit: 0` means no limit. The `limit` and `more` options set both for every folder; a folder's own lines win.
111112

113+
### Grouping
114+
115+
`.group: month` puts the entries a `.sidebar` doesn't list into one group per month of their date ("October 2026"), after sorting and `.limit`; `.group: year` into one per year. `.group: blog` groups a main blog's site-wide posts by the section blog they came from (see [Blogs](#blogs)).
116+
117+
- Each group sits where its first entry falls, so with posts newest first, the months run newest first too.
118+
- The month is the one the date is written in, whatever its offset.
119+
- Listed entries, subfolders and undated pages stay outside the groups.
120+
121+
### Blogs
122+
123+
With `blog: true`, each [Blog](/plugins/blog/) folder lists the posts its blog page lists. This site turns it on.
124+
125+
- A folder whose landing page is a blog (`blog-index`) and has no `.sort` lists its posts pinned first, then newest first.
126+
- The main blog's folder (`blog-index: { scope: site }`) also lists every `scope: site` post in the folders it covers, sorted in with its own. So a site-wide post in a section blog shows twice: in its section and in the main blog.
127+
- Those posts count toward `.limit`, and `.exclude` files and `excludeFrontmatter` hide them like any page.
128+
- `.group: blog` in the main blog's `.sidebar` puts them in one group per section blog, linked to its page. A section blog whose folder is right inside the main blog's already has its group there, so its posts aren't repeated.
129+
130+
The [Scopes Demo](/plugins/blog/demo/) in this sidebar shows it: its site-wide team post is listed under Scopes Demo and under Team Blog, and the section-only post only under Team Blog. The demo's `.sidebar` keeps the Team Blog group below the posts:
131+
132+
<<< @/plugins/blog/demo/.sidebar{txt}
133+
112134
### Recipes
113135

114136
`.sort` and `.limit` turn a folder that grows every week into a sidebar that stays short and current. Some realistic setups:
@@ -204,6 +226,7 @@ index.md:All decisions
204226
| `sort` | `'name'` | Order for unlisted entries in every folder, e.g. `'date desc'`. See [Sorting](#sorting). |
205227
| `limit` | `0` | Most unlisted entries every folder shows, after sorting. See [Limiting](#limiting). |
206228
| `more` | none | Link text for the landing page when a limit left entries out. |
229+
| `blog` | `false` | Follow [Blog](/plugins/blog/#scopes) scopes in blog folders. See [Blogs](#blogs). |
207230
| `groupTitleFromIndex` | `false` | Label a folder's group with its landing page's title. |
208231
| `verbose` | `false` | Log each folder as it is processed. |
209232

‎docs/plugins/blog/demo/.sidebar‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
index.md:Overview
2+
# Posts come next, newest first, including the team blog's site-wide post; the team blog goes last.
3+
...
24
team:Team Blog
3-
example-unsorted-post.md
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
index.md:Overview
2-
example-site-post.md
3-
example-section-post.md

‎docs/plugins/blog/index.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ The list goes where `<!-- blog-posts -->` is, or after the page's content if the
236236

237237
Before 0.4.0, these settings were called `sticky` and `stickyLimit`. The old names are still read, so older posts keep working.
238238

239-
To keep pinned posts on top of the sidebar too, sort the blog folder with [Auto Sidebar](/plugins/auto-sidebar/#sorting)'s `.sort` setting, by pinning and then date. This site's blog does:
239+
To keep pinned posts on top of the sidebar too, turn on [Auto Sidebar](/plugins/auto-sidebar/#blogs)'s `blog` option, or sort the blog folder with its `.sort` setting, by pinning and then date. This site's blog does both:
240240

241241
<<< @/blog/.sidebar{txt}
242242

@@ -363,6 +363,8 @@ Scopes decide which blog lists a post.
363363

364364
So a site with only a main blog needs no scope settings at all, and a post inside a section only reaches the main blog when it says `scope: site`. The [Scopes Demo](/plugins/blog/demo/) shows all three cases live.
365365

366+
[Auto Sidebar](/plugins/auto-sidebar/#blogs)'s `blog` option follows the same scopes: a `scope: site` post is listed in its section's folder and in the main blog's folder. A post in a folder with no section blog of its own stays in that folder's group.
367+
366368
```txt
367369
docs/
368370
blog/

‎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
@@ -26,8 +26,8 @@
2626
"devDependencies": {
2727
"@binarynoir/vite-plugin-image-fallback": "^0.4.3",
2828
"@binarynoir/vite-plugin-optimize-images": "^0.2.0",
29-
"@binarynoir/vitepress-auto-navbar": "^0.8.1",
30-
"@binarynoir/vitepress-auto-sidebar": "^0.10.1",
29+
"@binarynoir/vitepress-auto-navbar": "^0.8.2",
30+
"@binarynoir/vitepress-auto-sidebar": "^0.11.0",
3131
"@binarynoir/vitepress-blog": "^0.7.1",
3232
"@binarynoir/vitepress-broken-links": "^0.1.4",
3333
"@binarynoir/vitepress-downloads": "^0.1.5",

0 commit comments

Comments
 (0)