Skip to content

Commit a0b192c

Browse files
authored
Revamped engine for static documentation in the Next.js site (#7)
* Implement proof of concept * Add remaining AI-generated operators/commands * Add anchor tags for H2 and H3 elements * Reducing generated YAML to minimal set * Update schema and rendering * Change devcontainer image and remove features Updated the development container configuration to use a different base image and removed some features. * Add SEO metadata keywords and cards * Fix URL for social media images * Update readme * Update NPM package versions * Fix typo
1 parent 9711097 commit a0b192c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+9522
-8367
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "DocumentDB Next.js Dev Container",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": [
7+
"redhat.vscode-yaml"
8+
]
9+
}
10+
},
11+
"forwardPorts": [
12+
3000
13+
],
14+
"postCreateCommand": "npm install"
15+
}

.github/scripts/ajv-to-ctrf.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Minimal AJV output to CTRF converter
2+
// Reads validation-output.txt and writes a dummy CTRF report
3+
4+
const fs = require('fs');
5+
const [, , inputPath, outputPath] = process.argv;
6+
7+
if (!inputPath || !outputPath) {
8+
console.error('Usage: node ajv-to-ctrf.js <input> <output>');
9+
process.exit(1);
10+
}
11+
12+
if (!fs.existsSync(inputPath)) {
13+
console.error(`Error: Input file not found: ${inputPath}`);
14+
fs.writeFileSync(outputPath, JSON.stringify({ version: '1.0', results: [], error: `Input file not found: ${inputPath}` }, null, 2));
15+
process.exit(0);
16+
}
17+
18+
const output = {
19+
version: '1.0',
20+
results: []
21+
};
22+
23+
try {
24+
const lines = fs.readFileSync(inputPath, 'utf-8').split('\n');
25+
let currentTest = null;
26+
27+
for (const line of lines) {
28+
const trimmed = line.trim();
29+
if (!trimmed) continue;
30+
31+
// Detect start of a new validation
32+
if (trimmed.startsWith('Validating:')) {
33+
if (currentTest) {
34+
output.results.push(currentTest);
35+
}
36+
const match = trimmed.match(/Validating:\s+(.+?)\s+against\s+(.+)/);
37+
if (match) {
38+
currentTest = {
39+
testName: match[1],
40+
status: 'unknown',
41+
message: `Validating ${match[1]} against ${match[2]}`,
42+
details: []
43+
};
44+
}
45+
}
46+
// Detect pass/fail status
47+
else if (trimmed.startsWith('✓ PASSED:')) {
48+
if (currentTest) {
49+
currentTest.status = 'pass';
50+
output.results.push(currentTest);
51+
currentTest = null;
52+
}
53+
}
54+
else if (trimmed.startsWith('✗ FAILED:')) {
55+
if (currentTest) {
56+
currentTest.status = 'fail';
57+
output.results.push(currentTest);
58+
currentTest = null;
59+
}
60+
}
61+
// Collect error details
62+
else if (currentTest && (trimmed.includes('error') || trimmed.includes('invalid') || trimmed.includes('must'))) {
63+
currentTest.details.push(trimmed);
64+
currentTest.message += '\n' + trimmed;
65+
}
66+
}
67+
68+
// Add last test if exists
69+
if (currentTest) {
70+
output.results.push(currentTest);
71+
}
72+
73+
// If no results, create a summary entry
74+
if (output.results.length === 0) {
75+
output.results.push({
76+
testName: 'YAML Schema Validation',
77+
status: 'pass',
78+
message: 'No validation results found or all files skipped'
79+
});
80+
}
81+
82+
fs.writeFileSync(outputPath, JSON.stringify(output, null, 2));
83+
console.log(`CTRF report generated: ${outputPath}`);
84+
console.log(`Total tests: ${output.results.length}`);
85+
console.log(`Passed: ${output.results.filter(r => r.status === 'pass').length}`);
86+
console.log(`Failed: ${output.results.filter(r => r.status === 'fail').length}`);
87+
} catch (err) {
88+
console.error('Error:', err);
89+
process.exit(1);
90+
}

.github/workflows/nextjs.yml renamed to .github/workflows/continuous-deployment.yml

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
# Workflow for building Next.js site and downloading DocumentDB packages, then deploying to GitHub Pages
22
name: Deploy Next.js site and DocumentDB packages to Pages
3-
43
on:
54
# Runs on pushes targeting the default branch
65
push:
7-
branches: ["main"]
8-
6+
branches:
7+
- main
98
# Allows you to run this workflow manually from the Actions tab
109
workflow_dispatch:
11-
12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13-
permissions:
14-
contents: read
15-
pages: write
16-
id-token: write
17-
1810
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1911
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2012
concurrency:
21-
group: "pages"
13+
group: pages
2214
cancel-in-progress: false
23-
2415
jobs:
2516
# Build job
2617
build:
18+
name: Build Next.js static site
19+
# Sets permissions of the GITHUB_TOKEN to allow reading of repository content
20+
permissions:
21+
contents: read
2722
runs-on: ubuntu-22.04
2823
steps:
29-
- name: Checkout
30-
uses: actions/checkout@v4
24+
- name: Checkout source
25+
uses: actions/checkout@v5
3126
- name: Install required packages
3227
run: |
3328
until sudo apt-get update; do sleep 1; done
@@ -72,19 +67,11 @@ jobs:
7267
echo "Unable to determine package manager"
7368
exit 1
7469
fi
75-
- name: Setup Node
76-
uses: actions/setup-node@v4
70+
- name: Setup Node.js
71+
uses: actions/setup-node@v5
7772
with:
78-
node-version: "20"
73+
node-version: 24
7974
cache: ${{ steps.detect-package-manager.outputs.manager }}
80-
- name: Setup Pages
81-
uses: actions/configure-pages@v5
82-
with:
83-
# Automatically inject basePath in your Next.js configuration file and disable
84-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
85-
#
86-
# You may remove this line if you want to manage the configuration yourself.
87-
static_site_generator: next
8875
- name: Restore cache
8976
uses: actions/cache@v4
9077
with:
@@ -98,22 +85,37 @@ jobs:
9885
- name: Install dependencies
9986
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
10087
- name: Build with Next.js
88+
env:
89+
NEXT_BASE_PATH: ${{ github.event.repository.name }}
10190
run: ${{ steps.detect-package-manager.outputs.runner }} next build
10291
- name: Download DocumentDB packages from latest release
10392
run: .github/scripts/download_packages.sh
10493
- name: Upload artifact
10594
uses: actions/upload-pages-artifact@v3
10695
with:
10796
path: ./out
108-
10997
# Deployment job
11098
deploy:
99+
name: Publish site to GitHub Pages
111100
environment:
112101
name: github-pages
113102
url: ${{ steps.deployment.outputs.page_url }}
114103
runs-on: ubuntu-latest
115-
needs: build
104+
needs:
105+
- build
106+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
107+
permissions:
108+
pages: write
109+
id-token: write
116110
steps:
111+
- name: Setup Pages
112+
uses: actions/configure-pages@v5
113+
with:
114+
# Automatically inject basePath in your Next.js configuration file and disable
115+
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
116+
#
117+
# You may remove this line if you want to manage the configuration yourself.
118+
static_site_generator: next
117119
- name: Deploy to GitHub Pages
118120
id: deployment
119121
uses: actions/deploy-pages@v4
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Validate structured content
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
yaml-schema-validation:
11+
name: Validate YAML files against schemas
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v5
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v5
18+
with:
19+
node-version: 24
20+
- name: Install dependencies
21+
run: |
22+
npm install yaml-ls-check
23+
- name: Validate YAML files
24+
run: |
25+
npx yaml-ls-check .\articles
26+
npx yaml-ls-check .\blogs
27+
npx yaml-ls-check .\reference

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Sourced from https://github.com/github/gitignore/blob/main/Nextjs.gitignore
2+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3+
4+
# dependencies
5+
/node_modules
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
.env
31+
32+
# vercel
33+
.vercel
34+
35+
# typescript
36+
*.tsbuildinfo
37+
next-env.d.ts

.vscode/settings.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"yaml.schemas": {
3+
"./schema/blog.content.schema.json": [
4+
"blogs/content.{yml,yaml}"
5+
],
6+
"./schema/reference.content.schema.json": [
7+
"reference/content.{yml,yaml}"
8+
],
9+
"./schema/reference.data.schema.json": [
10+
"reference/*/**/*.{yml,yaml}"
11+
],
12+
"./schema/articles.content.schema.json": [
13+
"articles/**/content.{yml,yaml}"
14+
],
15+
"./schema/articles.navigation.schema.json": [
16+
"articles/**/navigation.{yml,yaml}"
17+
]
18+
},
19+
"editor.tabSize": 2,
20+
"editor.insertSpaces": true
21+
}

0 commit comments

Comments
 (0)