Skip to content

Commit cc74199

Browse files
committed
docs: add pgflow documentation page with comprehensive overview and links
1 parent c5f45ae commit cc74199

File tree

4 files changed

+215
-43
lines changed

4 files changed

+215
-43
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: pgflow-docs
3+
description: Access pgflow documentation on-demand. Use when working with pgflow workflows, Supabase integration, or understanding flow concepts.
4+
---
5+
6+
# pgflow Documentation
7+
8+
```bash
9+
curl -s https://www.pgflow.dev/toc.md
10+
```

pkgs/website/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"astro": "^5.7.14",
2424
"astro-d2": "^0.8.0",
2525
"astro-robots-txt": "^1.0.0",
26+
"micromatch": "^4.0.8",
2627
"react": "^19.1.1",
2728
"react-dom": "^19.1.1",
2829
"sharp": "^0.33.5",
@@ -35,6 +36,7 @@
3536
"typescript": "^5.8.3"
3637
},
3738
"devDependencies": {
39+
"@types/micromatch": "^4.0.10",
3840
"prettier-plugin-astro": "^0.14.1",
3941
"wrangler": "^4.20.3"
4042
}

pkgs/website/src/pages/toc.md.ts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import type { APIRoute } from 'astro';
2+
import { getCollection } from 'astro:content';
3+
import micromatch from 'micromatch';
4+
5+
const BASE_URL = 'https://www.pgflow.dev';
6+
7+
const TOPIC_ORDER = [
8+
'get-started',
9+
'build',
10+
'deploy',
11+
'concepts',
12+
'reference',
13+
'tutorials',
14+
'comparisons',
15+
];
16+
17+
const TOPIC_LABELS: Record<string, string> = {
18+
'get-started': 'Get Started',
19+
build: 'Build',
20+
deploy: 'Deploy',
21+
concepts: 'Concepts',
22+
reference: 'Reference',
23+
tutorials: 'Tutorials',
24+
comparisons: 'Comparisons',
25+
};
26+
27+
const DEPRIORITIZED_PATTERNS = [
28+
'reference/manual-installation',
29+
'deploy/connection-string',
30+
'deploy/prune-records',
31+
'deploy/troubleshooting-connections',
32+
'reference/queue-worker/*',
33+
'comparisons/*',
34+
];
35+
36+
function isDeprioritized(slug: string, patterns: string[]): boolean {
37+
return micromatch.isMatch(slug, patterns);
38+
}
39+
40+
function getTopicFromSlug(slug: string): string {
41+
const parts = slug.split('/');
42+
return parts[0] || '';
43+
}
44+
45+
function getDocPath(slug: string): string {
46+
return `${BASE_URL}/${slug}/index.md`;
47+
}
48+
49+
export const GET: APIRoute = async () => {
50+
const docs = await getCollection('docs');
51+
52+
const prioritizedDocs = docs.filter(
53+
(doc) => !isDeprioritized(doc.id, DEPRIORITIZED_PATTERNS)
54+
);
55+
const deprioritizedDocs = docs.filter((doc) =>
56+
isDeprioritized(doc.id, DEPRIORITIZED_PATTERNS)
57+
);
58+
59+
const groupedByTopic: Record<string, typeof docs> = {};
60+
for (const doc of prioritizedDocs) {
61+
const topic = getTopicFromSlug(doc.id);
62+
if (!groupedByTopic[topic]) {
63+
groupedByTopic[topic] = [];
64+
}
65+
groupedByTopic[topic].push(doc);
66+
}
67+
68+
const lines: string[] = [
69+
'# pgflow Documentation',
70+
'',
71+
'All links below are raw markdown files:',
72+
'',
73+
'```bash',
74+
'curl -s https://www.pgflow.dev/get-started/installation/index.md',
75+
'```',
76+
'',
77+
];
78+
79+
for (const topicId of TOPIC_ORDER) {
80+
const topicDocs = groupedByTopic[topicId];
81+
if (!topicDocs || topicDocs.length === 0) continue;
82+
83+
const topicLabel = TOPIC_LABELS[topicId] || topicId;
84+
lines.push(`## ${topicLabel}`);
85+
lines.push('');
86+
87+
const sortedDocs = [...topicDocs].sort((a, b) => {
88+
const aOrder = a.data.sidebar?.order ?? 999;
89+
const bOrder = b.data.sidebar?.order ?? 999;
90+
return aOrder - bOrder;
91+
});
92+
93+
for (const doc of sortedDocs) {
94+
const title = doc.data.title;
95+
const description = doc.data.description || '';
96+
const path = getDocPath(doc.id);
97+
const line = description
98+
? `- [${title}](${path}) - ${description}`
99+
: `- [${title}](${path})`;
100+
lines.push(line);
101+
}
102+
lines.push('');
103+
}
104+
105+
if (deprioritizedDocs.length > 0) {
106+
lines.push('---');
107+
lines.push('');
108+
lines.push('## Niche / Advanced');
109+
lines.push('');
110+
lines.push(
111+
'> Only use these if you know what you are doing or have specific needs.'
112+
);
113+
lines.push('');
114+
115+
const sortedDeprioritized = [...deprioritizedDocs].sort((a, b) => {
116+
const aOrder = a.data.sidebar?.order ?? 999;
117+
const bOrder = b.data.sidebar?.order ?? 999;
118+
return aOrder - bOrder;
119+
});
120+
121+
for (const doc of sortedDeprioritized) {
122+
const title = doc.data.title;
123+
const path = getDocPath(doc.id);
124+
lines.push(`- [${title}](${path})`);
125+
}
126+
}
127+
128+
return new Response(lines.join('\n'), {
129+
headers: {
130+
'Content-Type': 'text/markdown; charset=utf-8',
131+
},
132+
});
133+
};

0 commit comments

Comments
 (0)