Skip to content

Commit 7f3e45e

Browse files
committed
Use licensed tailwindui template
1 parent 3e0fb0c commit 7f3e45e

File tree

220 files changed

+45200
-4056
lines changed

Some content is hidden

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

220 files changed

+45200
-4056
lines changed

generate_markdown.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const yaml = require('js-yaml');
4+
5+
// Load the JSON data
6+
const allDocuments = require('./schema/all_documents.json');
7+
8+
// Function to create directory if it doesn't exist
9+
function ensureDirectoryExists(dirPath) {
10+
if (!fs.existsSync(dirPath)) {
11+
fs.mkdirSync(dirPath, { recursive: true });
12+
}
13+
}
14+
15+
// Function to generate markdown content from a page object
16+
function generateMarkdown(page) {
17+
if (!page) return null;
18+
19+
// Extract title from title/value
20+
const title = page.title && page.title.value ? page.title.value : 'Untitled';
21+
22+
// Extract slug
23+
const slug = page.slug || '';
24+
25+
// Extract SEO metadata (removing @type)
26+
const seo = page.seo_metadata ? { ...page.seo_metadata } : {};
27+
delete seo['@type'];
28+
29+
// Extract media array with titles
30+
const media = page.media ? page.media.map(item => {
31+
const mediaObj = { ...item };
32+
if (mediaObj.title && mediaObj.title.value) {
33+
mediaObj.title = mediaObj.title.value;
34+
}
35+
delete mediaObj['@type'];
36+
return mediaObj;
37+
}) : [];
38+
39+
// Extract body content
40+
const bodyContent = page.body && page.body.value ? page.body.value : '';
41+
42+
// Create frontmatter object
43+
const frontmatter = {
44+
title,
45+
slug,
46+
seo,
47+
media
48+
};
49+
50+
// Convert to YAML and create markdown content
51+
const yamlContent = yaml.dump(frontmatter);
52+
const markdownContent = `---\n${yamlContent}---\n\n${bodyContent}`;
53+
54+
return markdownContent;
55+
}
56+
57+
// Function to process all documents and generate files
58+
function processAllDocuments(documents) {
59+
documents.forEach(doc => {
60+
if (doc['@type'] === 'Page' && doc.slug) {
61+
const slug = doc.slug;
62+
63+
// Special case for index page
64+
if (slug === 'index') {
65+
const dirPath = path.join(__dirname, 'src', 'app', 'docs');
66+
ensureDirectoryExists(dirPath);
67+
68+
const markdownContent = generateMarkdown(doc);
69+
if (markdownContent) {
70+
fs.writeFileSync(path.join(dirPath, 'page.md'), markdownContent);
71+
console.log(`Created: docs/page.md (index)`);
72+
}
73+
} else {
74+
const dirPath = path.join(__dirname, 'src', 'app', 'docs', slug);
75+
ensureDirectoryExists(dirPath);
76+
77+
const markdownContent = generateMarkdown(doc);
78+
if (markdownContent) {
79+
fs.writeFileSync(path.join(dirPath, 'page.md'), markdownContent);
80+
console.log(`Created: docs/${slug}/page.md`);
81+
}
82+
}
83+
}
84+
});
85+
}
86+
87+
// Main execution
88+
console.log('Starting markdown generation...');
89+
processAllDocuments(allDocuments);
90+
console.log('Markdown generation complete!');

next.config.js renamed to next.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import withMarkdoc from '@markdoc/next.js'
2+
3+
import withSearch from './src/markdoc/search.mjs'
4+
15
/** @type {import('next').NextConfig} */
26
const nextConfig = {
37
basePath: process.env.BASE_PATH || "",
@@ -12,6 +16,9 @@ const nextConfig = {
1216
'swagger-client',
1317
'react-syntax-highlighter',
1418
],
19+
pageExtensions: ['js', 'jsx', 'md', 'ts', 'tsx'],
1520
}
1621

17-
module.exports = nextConfig
22+
export default withSearch(
23+
withMarkdoc({ schemaPath: './src/markdoc' })(nextConfig),
24+
)

0 commit comments

Comments
 (0)