Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ async function initializeApiIndex(program: Command) {
}

async function buildProject(program: Command): Promise<DocsConfig | undefined> {
const { verbose } = program.opts()
const { verbose, apiOnly } = program.opts()

if (apiOnly) {
process.env.PF_API_ONLY = 'true'
}

if (!config) {
console.error(
Expand Down Expand Up @@ -191,6 +195,7 @@ program.name('pf-doc-core')
program.option('--verbose', 'verbose mode', false)
program.option('--props', 'generate props data', false)
program.option('--dry-run', 'dry run mode', false)
program.option('--api-only', 'only build API and component pages, skip standalone content pages', false)

program.command('setup').action(async () => {
await Promise.all([
Expand All @@ -212,6 +217,10 @@ program.command('init').action(async () => {
})

program.command('start').action(async () => {
const { apiOnly } = program.opts()
if (apiOnly) {
process.env.PF_API_ONLY = 'true'
}
await updateContent(program)
await initializeApiIndex(program)

Expand Down
22 changes: 22 additions & 0 deletions src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
const apiOnly = process.env.PF_API_ONLY === 'true'
---

<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>404 - Not Found</title>
</head>
<body>
{apiOnly ? (
<>
<h1>404 - Not Found</h1>
<p>This build only serves API routes. Content pages are not available.</p>
<p>Available endpoints are under <a href="/api">/api</a>.</p>
</>
) : (
<h1>404 - Page not found</h1>
)}
</body>
</html>
6 changes: 6 additions & 0 deletions src/pages/[section]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ import {
import DocsTables from '../../components/DocsTables.astro'

export async function getStaticPaths() {
const apiOnly = process.env.PF_API_ONLY === 'true'

if (apiOnly) {
return []
}

const collections = await Promise.all(
content.map(
async (entry) => await getCollection(entry.name as 'textContent'),
Expand Down
6 changes: 6 additions & 0 deletions src/pages/[section]/[page]/[tab].astro
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import DocsTables from '../../../components/DocsTables.astro'
import { addDemosOrDeprecated, getDefaultTab } from '../../../utils'

export async function getStaticPaths() {
const apiOnly = process.env.PF_API_ONLY === 'true'

if (apiOnly) {
return []
}

const collections = await Promise.all(
content.map(
async (entry) => await getCollection(entry.name as 'textContent'),
Expand Down
12 changes: 11 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
import MainLayout from '../layouts/Main.astro'

const apiOnly = process.env.PF_API_ONLY === 'true'
---

<html lang="en">
Expand All @@ -11,6 +13,14 @@ import MainLayout from '../layouts/Main.astro'
<title>PatternFly</title>
</head>
<body>
<MainLayout title="PatternFly X Astro"> Page content </MainLayout>
{apiOnly ? (
<>
<h1>PatternFly API</h1>
<p>This build only serves API routes. Content pages are not available.</p>
<p>Available endpoints are under <a href="/api">/api</a>.</p>
</>
) : (
<MainLayout title="PatternFly X Astro"> Page content </MainLayout>
)}
</body>
</html>
Loading