chore: fix linting and build errors
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🧪 QA (push) Failing after 1m31s
Build & Deploy / 🏗️ Build (push) Failing after 3m51s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🧪 QA (push) Failing after 1m31s
Build & Deploy / 🏗️ Build (push) Failing after 3m51s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
62
apps/web/scripts/fix-fenced-mermaid.ts
Normal file
62
apps/web/scripts/fix-fenced-mermaid.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const MDX_DIR = path.join(process.cwd(), 'content/blog');
|
||||
const TARGET_FILE = process.argv[2] ? path.resolve(process.argv[2]) : null;
|
||||
|
||||
function fixFencedMermaid(content: string): string {
|
||||
// Regex to find fenced mermaid blocks
|
||||
// ```mermaid
|
||||
// graph TD...
|
||||
// ```
|
||||
const fencedRegex = /```mermaid\n([\s\S]*?)\n```/g;
|
||||
|
||||
return content.replace(fencedRegex, (match, code) => {
|
||||
// Generate a random ID or use a placeholder
|
||||
const id = `diagram-${Math.random().toString(36).substr(2, 9)}`;
|
||||
return `<div className="my-12">
|
||||
<Mermaid id="${id}" title="Generated Diagram" showShare={true}>
|
||||
${code.trim()}
|
||||
</Mermaid>
|
||||
</div>`;
|
||||
});
|
||||
}
|
||||
|
||||
function processFiles() {
|
||||
if (TARGET_FILE) {
|
||||
console.log(`Processing single file: ${TARGET_FILE}`);
|
||||
if (fs.existsSync(TARGET_FILE)) {
|
||||
const content = fs.readFileSync(TARGET_FILE, 'utf8');
|
||||
const fixed = fixFencedMermaid(content);
|
||||
if (content !== fixed) {
|
||||
fs.writeFileSync(TARGET_FILE, fixed);
|
||||
console.log(`✅ Fixed fenced mermaid in: ${TARGET_FILE}`);
|
||||
} else {
|
||||
console.log(`- No changes needed.`);
|
||||
}
|
||||
} else {
|
||||
console.error(`File not found: ${TARGET_FILE}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(MDX_DIR).filter(f => f.endsWith('.mdx'));
|
||||
let fixCount = 0;
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(MDX_DIR, file);
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
const fixed = fixFencedMermaid(content);
|
||||
|
||||
if (content !== fixed) {
|
||||
fs.writeFileSync(filePath, fixed);
|
||||
fixCount++;
|
||||
console.log(`✅ Fixed fenced mermaid in: ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nTotal fixed: ${fixCount}`);
|
||||
}
|
||||
|
||||
processFiles();
|
||||
Reference in New Issue
Block a user