Build Your Kit page and full Micromelon website

Complete website build including:
- Build Your Kit store page with cart system, sectioned layout
  (Hardware, Software, Attachments, Spare Parts), inline quote
  request form, and sticky sidebar summary
- 16+ pages: Education, Platform, Resources, News, About Us,
  Download, Contact, Rover, Code Editor, Robot Simulator, etc.
- 89+ MDX resource articles and 18 news posts
- Store product images scraped from micromelon.com.au
- Quote request API route with Airtable integration
- Dynamic back links and cover photos on resource pages
- Redesigned downloads page
- Fixed corrupted MDX code blocks
This commit is contained in:
Tim Hadwen
2026-02-28 19:00:42 +10:00
parent 5233233662
commit 707c49dd3f
320 changed files with 22333 additions and 107 deletions

View File

@@ -0,0 +1,59 @@
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const contentDir = path.join(__dirname, "..", "content", "resources");
const files = fs.readdirSync(contentDir).filter((f) => f.endsWith(".mdx"));
let totalFixed = 0;
for (const file of files) {
const filePath = path.join(contentDir, file);
const raw = fs.readFileSync(filePath, "utf-8");
// Split frontmatter from content
const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
if (!fmMatch) continue;
const frontmatter = fmMatch[1];
const content = fmMatch[2];
const lines = content.split("\n");
let insideFencedBlock = false;
let changed = false;
const result = [];
for (let line of lines) {
// Toggle fenced code block state
if (/^```/.test(line.trimStart())) {
insideFencedBlock = !insideFencedBlock;
result.push(line);
continue;
}
if (insideFencedBlock) {
// Inside fenced code block: unescape HTML entities
const newLine = line.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
if (newLine !== line) changed = true;
result.push(newLine);
} else {
// Outside fenced block: fix inline code spans
const newLine = line.replace(/`[^`]+`/g, (match) => {
return match.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
});
if (newLine !== line) changed = true;
result.push(newLine);
}
}
if (changed) {
const output = `---\n${frontmatter}\n---\n${result.join("\n")}`;
fs.writeFileSync(filePath, output, "utf-8");
totalFixed++;
console.log(`Fixed: ${file}`);
}
}
console.log(`\nDone. Fixed ${totalFixed} files.`);