mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
refactor(schema): simplify validation and OpenAPI generation (#2709)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import {readdir} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
|
||||
export const DOCS_ROOT = fileURLToPath(new URL('../src/content/docs/', import.meta.url));
|
||||
|
||||
export async function listMarkdownFiles(directory: string): Promise<Array<string>> {
|
||||
const files: Array<string> = [];
|
||||
for (const entry of await readdir(directory, {withFileTypes: true})) {
|
||||
if (entry.name === 'node_modules') {
|
||||
continue;
|
||||
}
|
||||
const resolved = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
files.push(...(await listMarkdownFiles(resolved)));
|
||||
} else if (/\.mdx?$/u.test(entry.name)) {
|
||||
files.push(resolved);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
export function slugifyHeading(heading: string): string {
|
||||
return heading
|
||||
.replace(/`/gu, '')
|
||||
.replace(/\[([^\]]*)\]\([^)]*\)/gu, '$1')
|
||||
.replace(/<[^>]*>/gu, '')
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9\s-]/gu, '')
|
||||
.trim()
|
||||
.replace(/\s+/gu, '-');
|
||||
}
|
||||
Reference in New Issue
Block a user