You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cfe7506
Browse filesBrowse the repository at this point in the historyBrowse files
feat(docs): leave drafts out of the production build
- docs: document drafts in frontmatter for Exclude, Auto Sidebar, Auto Navbar and the blog, with a live demo page
- config: leave pages marked draft (or blog.draft) out of production builds, sidebars and navbars
- deps: vitepress-exclude 0.2.0, auto-sidebar 0.10.0, auto-navbar 0.8.0
|`excludeFrontmatter`|`[]`| Frontmatter keys that hide a page when `true`, such as `['draft', 'blog.draft']`. See [Exclude](/plugins/exclude/#drafts-in-frontmatter). |
60
+
|`indexTitle`|`'Overview'`| Label for the dropdown entry that links to the folder's landing page. |
61
+
|`flattenSinglePage`|`true`| A folder with one entry becomes a plain link. |
62
+
|`activeMatch`|`true`| Keep items highlighted on every page beneath them. |
63
+
|`titleReplacements`|`{}`| Words to replace in titles made from file and folder names. |
64
+
|`titleCase`|`true`| Title-case titles made from file and folder names. |
65
+
|`stripTags`|`true`| Remove Markdown Tags syntax (`((tag\|draft))`) from titles. |
66
+
|`transformTitle`| none | A function that gets every title before truncation. |
67
+
|`sort`|`'name'`| Order for unlisted entries in every folder, e.g. `'date desc'`. See [Settings](#settings). |
68
+
|`limit`|`0`| Most unlisted entries every dropdown shows, after sorting. |
69
+
|`more`| none | Link text for the landing page when a limit left entries out. |
70
+
|`verbose`|`false`| Log each folder as it is processed. |
70
71
71
72
Titles can be single- or double-quoted, with a space after the colon if you like, and a line that can't be parsed logs a warning with its file and line number.
|`excludeFrontmatter`|`[]`| Frontmatter keys that hide a page when `true`, such as `['draft', 'blog.draft']`. See [Exclude](/plugins/exclude/#drafts-in-frontmatter). |
198
+
|`collapsed`|`false`| Initial collapsed state for section headers. |
199
+
|`flattenSinglePage`|`true`| A folder with one page becomes a plain link instead of its own group. |
200
+
|`titleReplacements`|`{}`| Words to replace in titles made from file and folder names. |
201
+
|`titleCase`|`true`| Title-case titles made from file and folder names. |
202
+
|`stripTags`|`true`| Remove Markdown Tags syntax (`((tag\|draft))`) from titles. |
203
+
|`transformTitle`| none | A function that gets every title before truncation. |
204
+
|`sort`|`'name'`| Order for unlisted entries in every folder, e.g. `'date desc'`. See [Sorting](#sorting). |
205
+
|`limit`|`0`| Most unlisted entries every folder shows, after sorting. See [Limiting](#limiting). |
206
+
|`more`| none | Link text for the landing page when a limit left entries out. |
207
+
|`groupTitleFromIndex`|`false`| Label a folder's group with its landing page's title. |
208
+
|`verbose`|`false`| Log each folder as it is processed. |
Copy file name to clipboardExpand all lines: docs/plugins/blog/index.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,7 +136,7 @@ blog:
136
136
|`category`| none | Written to the feed and `article:section`. |
137
137
|`scope`|`section`|`site` (or `global`) also lists the post on the main blog. See [Scopes](#scopes). |
138
138
|`sticky`|`false`| Pinned to the top of its blog pages, above the paginated posts, with a Pinned badge. See [Sticky posts](#sticky-posts). |
139
-
|`draft`|`false`| Left out of lists and feeds. The page is still built: use [Exclude](/plugins/exclude/) to hide it. |
139
+
|`draft`|`false`| Left out of lists and feeds. To leave drafts out of the build and the menus too, see [Drafts](#drafts).|
140
140
|`byline`| the `byline` option |`false` hides this post's byline. |
141
141
|`cover`| the `cover` option |`true` shows this post's image under its byline. |
142
142
|`postNav`| the `postNav` option |`false` hides this post's newer / older links. |
@@ -168,6 +168,12 @@ blog:
168
168
- **Posts on the same day sort by their times**, and a date alone counts as the start of its day. Feeds and social tags use the exact moment.
169
169
- **The sidebar and navbar sort the same way.** [Auto Sidebar](/plugins/auto-sidebar/#sorting) and [Auto Navbar](/plugins/auto-navbar#settings) read dates with times too, so `.sort: date desc` puts this afternoon's post above this morning's.
170
170
171
+
### Drafts
172
+
173
+
`draft: true` keeps a post out of blog lists, `::: blog-posts` blocks and feeds, but on its own the page is still built and can be opened by its URL. With the `drafts` option on, drafts are listed too, with a Draft badge.
174
+
175
+
This site goes further: [Exclude](/plugins/exclude/#drafts-in-frontmatter)'s `excludeFrontmatter` option, with `blog.draft` in its list, leaves drafts out of the production build, and the same option in Auto Sidebar and Auto Navbar hides them from the menus. In `vitepress dev`, drafts are built and listed with their badge, for preview.
176
+
171
177
## Making a blog page
172
178
173
179
A page with `blog-index` in its frontmatter lists posts. `blog-index: true` is a section blog of the page's own folder:
This page is in the repository, but not on the published site. Its frontmatter says `draft: true`, and the site's config passes `excludeFrontmatter: ['draft', 'blog.draft']` to Exclude, Auto Sidebar and Auto Navbar for production builds. So it is left out of the build, the sidebar, the navbar, search and the sitemap.
9
+
10
+
`npm run docs:dev` still builds it, so drafts can be previewed while they are written. Remove `draft: true` and it is published with the next build.
0 commit comments