Skip to content

Commit bc28c6d

Browse files
authored
Merge pull request #57 from barocss/feat/feature-expansion
feat: feature expansion — blog, changelog, versioning, OpenAPI, API playground, and 7 more
2 parents e162d15 + a3ea90d commit bc28c6d

36 files changed

Lines changed: 2519 additions & 40 deletions

.changeset/feature-expansion.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
"@barodoc/core": minor
3+
"@barodoc/theme-docs": minor
4+
---
5+
6+
Add 12 new features across 4 phases
7+
8+
**Phase 1: Quick Wins**
9+
- Image zoom/lightbox with medium-zoom (auto-applied to all prose images)
10+
- Video embed component (YouTube, Vimeo, Loom auto-detect)
11+
- Math/KaTeX support via remark-math + rehype-katex ($inline$ and $$block$$)
12+
- Reading time display on docs pages
13+
- Keyboard shortcuts (Cmd/Ctrl+K search, arrow keys navigation, ? help modal)
14+
15+
**Phase 2: Content Types**
16+
- Blog system with content collection, card grid index, and dedicated BlogLayout
17+
- Changelog page with timeline UI and version badge grouping
18+
19+
**Phase 3: Plugins**
20+
- @barodoc/plugin-docsearch: Algolia DocSearch integration
21+
- @barodoc/plugin-rss: RSS feed generation from blog/changelog collections
22+
- @barodoc/plugin-pwa: PWA manifest and service worker for offline support
23+
- Page contributors component using git log with Gravatar avatars
24+
25+
**Phase 4: Major Features**
26+
- Doc versioning with folder-based version management and VersionSwitcher dropdown
27+
- @barodoc/plugin-openapi: OpenAPI spec auto-generation into MDX pages
28+
- API Playground component for interactive API testing with form builder

docs/src/content/config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@ const docsCollection = defineCollection({
1414
}),
1515
});
1616

17+
const blogCollection = defineCollection({
18+
type: "content",
19+
schema: z.object({
20+
title: z.string(),
21+
description: z.string().optional(),
22+
excerpt: z.string().optional(),
23+
date: z.coerce.date().optional(),
24+
author: z.string().optional(),
25+
image: z.string().optional(),
26+
tags: z.array(z.string()).optional(),
27+
}),
28+
});
29+
30+
const changelogCollection = defineCollection({
31+
type: "content",
32+
schema: z.object({
33+
title: z.string().optional(),
34+
version: z.string(),
35+
date: z.coerce.date(),
36+
}),
37+
});
38+
1739
export const collections = {
1840
docs: docsCollection,
41+
blog: blogCollection,
42+
changelog: changelogCollection,
1943
};

packages/barodoc/src/runtime/project.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,32 @@ const docsCollection = defineCollection({
272272
}),
273273
});
274274
275+
const blogCollection = defineCollection({
276+
type: "content",
277+
schema: z.object({
278+
title: z.string(),
279+
description: z.string().optional(),
280+
excerpt: z.string().optional(),
281+
date: z.coerce.date().optional(),
282+
author: z.string().optional(),
283+
image: z.string().optional(),
284+
tags: z.array(z.string()).optional(),
285+
}),
286+
});
287+
288+
const changelogCollection = defineCollection({
289+
type: "content",
290+
schema: z.object({
291+
title: z.string().optional(),
292+
version: z.string(),
293+
date: z.coerce.date(),
294+
}),
295+
});
296+
275297
export const collections = {
276298
docs: docsCollection,
299+
blog: blogCollection,
300+
changelog: changelogCollection,
277301
};
278302
`;
279303
}

packages/core/src/config/schema.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ export const pluginConfigSchema = z.union([
8787
z.tuple([z.string(), z.record(z.unknown())]),
8888
]);
8989

90+
export const blogConfigSchema = z.object({
91+
enabled: z.boolean().optional(),
92+
}).optional();
93+
94+
export const versionConfigSchema = z.object({
95+
label: z.string(),
96+
path: z.string(),
97+
}).strict();
98+
99+
export const versionsSchema = z.array(versionConfigSchema).optional();
100+
90101
export const barodocConfigSchema = z.object({
91102
name: z.string(),
92103
logo: z.string().optional(),
@@ -103,6 +114,8 @@ export const barodocConfigSchema = z.object({
103114
lastUpdated: z.boolean().optional(),
104115
announcement: announcementSchema,
105116
feedback: feedbackSchema,
117+
blog: blogConfigSchema,
118+
versions: versionsSchema,
106119
plugins: z.array(pluginConfigSchema).optional(),
107120
customCss: z.array(z.string()).optional(),
108121
});

packages/core/src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ export interface BarodocConfig {
8383
endpoint?: string;
8484
};
8585

86+
blog?: {
87+
enabled?: boolean;
88+
};
89+
90+
versions?: {
91+
label: string;
92+
path: string;
93+
}[];
94+
8695
plugins?: PluginConfig[];
8796

8897
customCss?: string[];
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@barodoc/plugin-docsearch",
3+
"version": "5.0.0",
4+
"description": "Algolia DocSearch plugin for Barodoc",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.js"
12+
}
13+
},
14+
"files": [
15+
"dist"
16+
],
17+
"scripts": {
18+
"build": "tsup src/index.ts --format esm --dts --clean",
19+
"dev": "tsup src/index.ts --format esm --dts --watch"
20+
},
21+
"peerDependencies": {
22+
"@barodoc/core": "workspace:*",
23+
"astro": "^5.0.0"
24+
},
25+
"devDependencies": {
26+
"@barodoc/core": "workspace:*",
27+
"@types/node": "^22.0.0",
28+
"astro": "^5.0.0",
29+
"tsup": "^8.3.0",
30+
"typescript": "^5.7.0"
31+
},
32+
"license": "MIT"
33+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import type { AstroIntegration } from "astro";
2+
import { definePlugin } from "@barodoc/core";
3+
4+
export interface DocSearchPluginOptions {
5+
appId: string;
6+
apiKey: string;
7+
indexName: string;
8+
container?: string;
9+
placeholder?: string;
10+
}
11+
12+
export default definePlugin<DocSearchPluginOptions>((options) => {
13+
return {
14+
name: "@barodoc/plugin-docsearch",
15+
hooks: {
16+
"config:loaded": (config) => {
17+
return {
18+
...config,
19+
search: { ...config.search, enabled: false },
20+
};
21+
},
22+
},
23+
astroIntegration: () => {
24+
const integration: AstroIntegration = {
25+
name: "@barodoc/plugin-docsearch",
26+
hooks: {
27+
"astro:config:setup": ({ injectScript }) => {
28+
const cssUrl = "https://cdn.jsdelivr.net/npm/@docsearch/css@3/dist/style.min.css";
29+
const jsUrl = "https://cdn.jsdelivr.net/npm/@docsearch/js@3";
30+
31+
injectScript(
32+
"head-inline",
33+
`document.head.insertAdjacentHTML('beforeend', '<link rel="stylesheet" href="${cssUrl}" />');`
34+
);
35+
36+
injectScript(
37+
"page",
38+
`
39+
import docsearch from "${jsUrl}";
40+
41+
function initDocSearch() {
42+
const container = document.querySelector('${options.container || "#docsearch"}');
43+
if (!container || container.hasChildNodes()) return;
44+
docsearch({
45+
appId: "${options.appId}",
46+
apiKey: "${options.apiKey}",
47+
indexName: "${options.indexName}",
48+
container: "${options.container || "#docsearch"}",
49+
placeholder: "${options.placeholder || "Search docs..."}",
50+
});
51+
}
52+
53+
if (document.readyState === "complete") initDocSearch();
54+
else document.addEventListener("DOMContentLoaded", initDocSearch);
55+
document.addEventListener("astro:page-load", initDocSearch);
56+
`
57+
);
58+
},
59+
},
60+
};
61+
return integration;
62+
},
63+
};
64+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"declaration": true,
7+
"strict": true,
8+
"esModuleInterop": true,
9+
"skipLibCheck": true,
10+
"outDir": "dist"
11+
},
12+
"include": ["src"]
13+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@barodoc/plugin-openapi",
3+
"version": "5.0.0",
4+
"description": "OpenAPI/Swagger auto-generation plugin for Barodoc",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.js"
12+
}
13+
},
14+
"files": [
15+
"dist"
16+
],
17+
"scripts": {
18+
"build": "tsup src/index.ts --format esm --dts --clean",
19+
"dev": "tsup src/index.ts --format esm --dts --watch"
20+
},
21+
"dependencies": {
22+
"yaml": "^2.7.0"
23+
},
24+
"peerDependencies": {
25+
"@barodoc/core": "workspace:*",
26+
"astro": "^5.0.0"
27+
},
28+
"devDependencies": {
29+
"@barodoc/core": "workspace:*",
30+
"@types/node": "^22.0.0",
31+
"astro": "^5.0.0",
32+
"tsup": "^8.3.0",
33+
"typescript": "^5.7.0"
34+
},
35+
"license": "MIT"
36+
}

0 commit comments

Comments
 (0)