-
Notifications
You must be signed in to change notification settings - Fork 418
Add draft docs mechanism (VITE_SHOW_DRAFTS) #2637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Show draft documentation pages in the sidebar and allow direct URL access. | ||
| # Pages marked `draft: true` are hidden in production builds. | ||
| # VITE_SHOW_DRAFTS=true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,21 @@ const SLUG_REDIRECTS: Record<string, string> = { | |
| "migration-workbench": "code-agents-ui", | ||
| }; | ||
|
|
||
| function DraftBanner() { | ||
| return ( | ||
| <div | ||
| className="mb-6 rounded-md border p-4 text-sm" | ||
| style={{ | ||
| borderColor: "var(--approaches-warn)", | ||
| color: "var(--approaches-warn)", | ||
| }} | ||
| > | ||
| <strong>Draft</strong> — This page is a work in progress. Content may be | ||
| incomplete or subject to change before publication. | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export async function loader({ params }: LoaderFunctionArgs) { | ||
| const slug = params.slug!; | ||
| if (isDocsLocale(slug)) { | ||
|
|
@@ -43,6 +58,9 @@ export async function loader({ params }: LoaderFunctionArgs) { | |
| if (!doc) { | ||
| throw new Response("Not Found", { status: 404 }); | ||
| } | ||
| if (doc.draft && import.meta.env.VITE_SHOW_DRAFTS !== "true") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Draft content remains exposed through generated Markdown assetsThis check protects only the React document route. The docs Vite agent-web build still enumerates all source documents, including drafts, and emits their Markdown twins plus sitemap/LLM discovery entries, so Additional Info |
||
| throw new Response("Not Found", { status: 404 }); | ||
| } | ||
| return doc; | ||
| } | ||
|
|
||
|
|
@@ -84,6 +102,7 @@ export default function DocPage() { | |
| docsMarkdownPathForDoc(doc.slug, DEFAULT_DOCS_LOCALE) ?? undefined | ||
| } | ||
| > | ||
| {doc.draft && <DraftBanner />} | ||
| <DocContent markdown={doc.body} /> | ||
| </DocsLayout> | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Nav filtering never reads draft frontmatter
toNavItemfilters only the staticNavItemConfig.draftfield, but this tree is not populated from theDocEntryfrontmatter parsed indocs-content.ts. As a result, an existing page markeddraft: trueremains visible in the sidebar with drafts disabled, then navigates to the new 404 route; derive or synchronize draft status from the document metadata.Additional Info