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();
|
||||
107
apps/web/scripts/optimize-blog-post.ts
Normal file
107
apps/web/scripts/optimize-blog-post.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
|
||||
import { ContentGenerator, OptimizationOptions } from "@mintel/content-engine";
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
async function main() {
|
||||
const OPENROUTER_KEY = process.env.OPENROUTER_KEY;
|
||||
if (!OPENROUTER_KEY) {
|
||||
console.error("❌ Error: OPENROUTER_KEY not found in environment.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
let targetFile = args[0];
|
||||
|
||||
if (!targetFile) {
|
||||
console.error("❌ Usage: npx tsx scripts/optimize-blog-post.ts <path/to/post.mdx>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Resolve absolute path
|
||||
if (!path.isAbsolute(targetFile)) {
|
||||
targetFile = path.resolve(process.cwd(), targetFile);
|
||||
}
|
||||
|
||||
console.log(`📄 Reading file: ${targetFile}`);
|
||||
let content = "";
|
||||
try {
|
||||
content = await fs.readFile(targetFile, "utf8");
|
||||
} catch (err: any) {
|
||||
console.error(`❌ Could not read file: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Backup original
|
||||
const backupPath = `${targetFile}.bak`;
|
||||
await fs.writeFile(backupPath, content);
|
||||
console.log(`💾 Backup created at: ${backupPath}`);
|
||||
|
||||
// Instantiate Generator
|
||||
const generator = new ContentGenerator(OPENROUTER_KEY);
|
||||
|
||||
const context = `
|
||||
Project: Mintel.me
|
||||
Style: Industrial, Technical, High-Performance, "No-BS".
|
||||
Author: Marc Mintel (Digital Architect).
|
||||
Focus: Web Architecture, PageSpeed, Core Web Vitals, Data-Driven Design.
|
||||
`;
|
||||
|
||||
// Define Optimization Options based on user request ("astrein verbessert mit daten gestützt, links zu quellen usw... mermaid, memes")
|
||||
const options: OptimizationOptions = {
|
||||
enhanceFacts: true,
|
||||
addMemes: true,
|
||||
addDiagrams: true,
|
||||
projectContext: context,
|
||||
availableComponents: [
|
||||
{
|
||||
name: "StatsDisplay",
|
||||
description: "A row of 3 clear statistic cards with values and labels.",
|
||||
usageExample: `<StatsDisplay
|
||||
items={[
|
||||
{ value: "-20%", label: "Conversion", description: "Source: Google" },
|
||||
{ value: "53%", label: "Bounce Rate", description: "Mobile users > 3s" },
|
||||
{ value: "0.1s", label: "Latency", description: "Edge Network" }
|
||||
]}
|
||||
/>`
|
||||
},
|
||||
{
|
||||
name: "ComparisonRow",
|
||||
description: "A comparison component showing a negative 'Standard' vs a positive 'Mintel' approach.",
|
||||
usageExample: `<ComparisonRow
|
||||
description="Architecture Comparison"
|
||||
negativeLabel="Legacy CMS"
|
||||
negativeText="Slow database queries, vulnerable plugins."
|
||||
positiveLabel="Mintel Stack"
|
||||
positiveText="Static generation, perfect security."
|
||||
/>`
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// 1. Separate Frontmatter from Body
|
||||
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
||||
const frontmatter = fmMatch ? fmMatch[0] : "";
|
||||
const body = fmMatch ? content.replace(frontmatter, "").trim() : content;
|
||||
|
||||
console.log("🚀 Starting Optimization via ContentEngine...");
|
||||
const result = await generator.optimizePost(body, options);
|
||||
|
||||
console.log("✅ Optimization Complete!");
|
||||
console.log(` - Added ${result.research.length} facts`);
|
||||
console.log(` - Added ${result.memes.length} meme concepts`);
|
||||
console.log(` - Generated ${result.diagrams.length} diagrams`);
|
||||
|
||||
// We write the content back (re-attaching frontmatter if it was there)
|
||||
const finalContent = frontmatter ? `${frontmatter}\n\n${result.content}` : result.content;
|
||||
|
||||
await fs.writeFile(targetFile, finalContent);
|
||||
|
||||
console.log(`💾 Saved optimized content to: ${targetFile}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user