@jxpeng98/vitepress-published-pages
v4.0.0
Published
VitePress config enhancer for frontmatter-driven published-page whitelists.
Maintainers
Readme
@jxpeng98/vitepress-published-pages
Frontmatter-driven published-page whitelist for VitePress.
What It Does
- Reads a frontmatter field such as
published: true - Excludes unpublished pages from
srcExcludeduring build - Filters
navandsidebarlinks that point at unpublished pages - Renders unpublished pages as 404 in
published-onlymode, even on direct URL access - Restarts the dev server when
publishedorexcludechanges, so navigation stays in sync - Disables sitemap output when a published-only build has no published pages
Usage
import { withPublishedPages } from '@jxpeng98/vitepress-published-pages/plugin'
import { withSidebar } from 'vitepress-sidebar'
export default ({ command }) =>
withPublishedPages(
withSidebar(vitePressOptions, vitePressSidebarOptions),
{
command,
scanRoots: ['en', 'zh'],
includeTopLevelMarkdown: true,
}
)Page frontmatter:
---
title: Public page
published: true
---Options
command: current VitePress command, usuallyserveorbuildrootDir: project root, defaults toprocess.cwd()scanRoots: directories to scan for markdown pages, defaults to['.']includeTopLevelMarkdown: whether root-level*.mdfiles should be scannedpublishedFieldName: frontmatter field used for whitelist, defaults topublishedsidebarExcludeFieldName: optional sidebar-only exclusion field, defaults toexcludepublishedOnlyEnvVar: env override, defaults toVITEPRESS_PUBLISHED_ONLYdefaultPublishedOnly: override the defaultbuild => true,serve => falsebehaviordisableSitemapWhenEmpty: defaults totrue
