Skip to content

Commit f10fb0e

Browse files
committed
Upgrade
Let's hope it doesn't explode ❤️
1 parent 546d606 commit f10fb0e

79 files changed

Lines changed: 9443 additions & 282 deletions

Some content is hidden

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

.astro/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"_variables": {
3+
"lastUpdateCheck": 1753692852857
4+
}
5+
}

.astro/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="astro/client" />

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
node-version: [16.x]
20+
node-version: [23.x]
2121
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2222

2323
steps:

astro.config.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'astro/config';
22
import preact from '@astrojs/preact';
33
import react from '@astrojs/react';
44
import sitemap from "@astrojs/sitemap";
5+
import mdx from '@astrojs/mdx';
56
import { h } from 'hastscript';
67
import rehypeSlugifyCounter from 'rehype-slugify-counter';
78

@@ -10,7 +11,7 @@ const AnchorLinkIcon = h('svg', {
1011
height: 16,
1112
version: 1.1,
1213
viewBox: '0 0 16 16',
13-
xlmns: 'http://www.w3.org/2000/svg'
14+
xmlns: 'http://www.w3.org/2000/svg'
1415
}, h('path', {
1516
fillRule: 'evenodd',
1617
fill: 'currentcolor',
@@ -19,13 +20,27 @@ const AnchorLinkIcon = h('svg', {
1920

2021
export default defineConfig({
2122
site: 'https://docs.k2vr.tech',
22-
integrations: [preact(), react(), sitemap()],
23+
integrations: [preact(), react(), sitemap(), mdx()],
24+
legacy: {
25+
astroFlavoredMarkdown: true
26+
},
27+
experimental: {
28+
contentCollectionCache: false
29+
},
30+
vite: {
31+
resolve: {
32+
alias: {
33+
'~': '/src',
34+
'@components': '/src/components',
35+
'@layouts': '/src/layouts',
36+
'@icons': '/src/icons'
37+
}
38+
}
39+
},
2340
markdown: {
24-
mode: 'mdx',
2541
syntaxHighlight: 'shiki',
42+
remarkPlugins: ['remark-gfm', 'remark-smartypants'],
2643
rehypePlugins: [
27-
// These are here because setting custom plugins disables the default plugins
28-
'remark-smartypants', 'remark-gfm',
2944
// This generates a set of IDs and numeric counters for headers
3045
rehypeSlugifyCounter,
3146
// This adds said IDs to headings
@@ -42,7 +57,7 @@ export default defineConfig({
4257
}, AnchorLinkIcon)]
4358
}]],
4459
shikiConfig: {
45-
theme: '../../../../../../src/srcery', // YES I KNOW THIS IS HACKY AS FUCK, IDC LOL
60+
theme: 'dark-plus',
4661
wrap: true
4762
}
4863
}

convert-markdown.mjs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
function convertMarkdownFile(filePath) {
9+
const content = fs.readFileSync(filePath, 'utf-8');
10+
11+
// Normalize line endings
12+
const normalizedContent = content.replace(/\r\n/g, '\n');
13+
14+
// Parse frontmatter
15+
const frontmatterMatch = normalizedContent.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
16+
if (!frontmatterMatch) {
17+
console.log(`No frontmatter found in ${filePath}`);
18+
return false;
19+
}
20+
21+
const [, frontmatter, markdownContent] = frontmatterMatch;
22+
23+
// Check if it has setup frontmatter
24+
const setupMatch = frontmatter.match(/setup:\s*\|\s*\n([\s\S]*?)(?=\n\w+:|$)/);
25+
if (!setupMatch) {
26+
console.log(`No setup found in ${filePath}`);
27+
return false;
28+
}
29+
30+
const setupCode = setupMatch[1].trim();
31+
32+
// Remove setup from frontmatter
33+
const newFrontmatter = frontmatter.replace(/setup:\s*\|\s*\n([\s\S]*?)(?=\n\w+:|$)/, '').trim();
34+
35+
// Create new content with imports at the top
36+
const newContent = `---\n${newFrontmatter}\n---\n${setupCode}\n\n${markdownContent}`;
37+
38+
// Write to .mdx file
39+
const mdxPath = filePath.replace('.md', '.mdx');
40+
fs.writeFileSync(mdxPath, newContent);
41+
42+
// Remove old .md file
43+
fs.unlinkSync(filePath);
44+
45+
console.log(`Converted ${filePath} to ${mdxPath}`);
46+
return true;
47+
}
48+
49+
function processDirectory(dirPath) {
50+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
51+
52+
for (const entry of entries) {
53+
const fullPath = path.join(dirPath, entry.name);
54+
55+
if (entry.isDirectory()) {
56+
processDirectory(fullPath);
57+
} else if (entry.isFile() && entry.name.endsWith('.md')) {
58+
convertMarkdownFile(fullPath);
59+
}
60+
}
61+
}
62+
63+
// Process src/pages directory
64+
const pagesDir = path.join(__dirname, 'src', 'pages');
65+
processDirectory(pagesDir);
66+
67+
console.log('Conversion complete!');

fix-mdx.mjs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
function fixMdxFile(filePath) {
9+
let content = fs.readFileSync(filePath, 'utf-8');
10+
let changed = false;
11+
12+
// Fix LinkButton tags specifically - they're case sensitive
13+
content = content.replace(/<linkButton([^>]*?)\s*\/\s*>([^<]+)<\/LinkButton>/gi, (match, attributes, innerContent) => {
14+
changed = true;
15+
return `<LinkButton${attributes}>${innerContent}</LinkButton>`;
16+
});
17+
18+
// Fix self-closing tags that shouldn't be self-closing
19+
const containerTags = ['CardTip', 'CardWarning', 'CardInfo', 'CardError', 'CardHelp', 'LinkButton', 'DownloadCard'];
20+
for (const tag of containerTags) {
21+
// Fix cases like <CardTip />content</CardTip>
22+
const regex = new RegExp(`<${tag}([^>]*?)\\s*\\/\\s*>([^<]+)<\\/${tag}>`, 'gi');
23+
content = content.replace(regex, (match, attributes, innerContent) => {
24+
changed = true;
25+
return `<${tag}${attributes}>${innerContent}</${tag}>`;
26+
});
27+
}
28+
29+
// Fix self-closing tags
30+
const selfClosingTags = ['br', 'img', 'hr', 'input', 'meta', 'link'];
31+
for (const tag of selfClosingTags) {
32+
const regex = new RegExp(`<${tag}([^>]*?)>(?!</)`, 'gi');
33+
const newContent = content.replace(regex, (match, attributes) => {
34+
if (!attributes.trim().endsWith('/')) {
35+
changed = true;
36+
return `<${tag}${attributes} />`;
37+
}
38+
return match;
39+
});
40+
content = newContent;
41+
}
42+
43+
// Fix unclosed br tags specifically
44+
content = content.replace(/<br>/gi, '<br />');
45+
if (content !== fs.readFileSync(filePath, 'utf-8')) changed = true;
46+
47+
if (changed) {
48+
fs.writeFileSync(filePath, content);
49+
console.log(`Fixed ${filePath}`);
50+
}
51+
}
52+
53+
function processDirectory(dirPath) {
54+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
55+
56+
for (const entry of entries) {
57+
const fullPath = path.join(dirPath, entry.name);
58+
59+
if (entry.isDirectory()) {
60+
processDirectory(fullPath);
61+
} else if (entry.isFile() && entry.name.endsWith('.mdx')) {
62+
fixMdxFile(fullPath);
63+
}
64+
}
65+
}
66+
67+
// Process src/pages directory
68+
const pagesDir = path.join(__dirname, 'src', 'pages');
69+
processDirectory(pagesDir);
70+
71+
console.log('MDX fixes complete!');

fix-mismatched.mjs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
function findMismatchedTags(content) {
9+
const matches = [];
10+
const tagRegex = /<(Card\w+)[^>]*>/g;
11+
const closeTagRegex = /<\/(Card\w+)>/g;
12+
13+
let match;
14+
const openTags = [];
15+
16+
// Find all opening tags
17+
while ((match = tagRegex.exec(content)) !== null) {
18+
openTags.push({
19+
tag: match[1],
20+
index: match.index,
21+
full: match[0]
22+
});
23+
}
24+
25+
// Find all closing tags
26+
const closeTags = [];
27+
while ((match = closeTagRegex.exec(content)) !== null) {
28+
closeTags.push({
29+
tag: match[1],
30+
index: match.index,
31+
full: match[0]
32+
});
33+
}
34+
35+
// Check for mismatches
36+
for (let i = 0; i < openTags.length && i < closeTags.length; i++) {
37+
if (openTags[i].tag !== closeTags[i].tag) {
38+
matches.push({
39+
openTag: openTags[i],
40+
closeTag: closeTags[i]
41+
});
42+
}
43+
}
44+
45+
return matches;
46+
}
47+
48+
function fixMismatchedTags(filePath) {
49+
let content = fs.readFileSync(filePath, 'utf-8');
50+
const mismatches = findMismatchedTags(content);
51+
52+
if (mismatches.length > 0) {
53+
console.log(`Found ${mismatches.length} mismatched tags in ${filePath}`);
54+
55+
// Fix from the end to preserve indices
56+
for (let i = mismatches.length - 1; i >= 0; i--) {
57+
const mismatch = mismatches[i];
58+
const correctCloseTag = `</${mismatch.openTag.tag}>`;
59+
60+
content = content.substring(0, mismatch.closeTag.index) +
61+
correctCloseTag +
62+
content.substring(mismatch.closeTag.index + mismatch.closeTag.full.length);
63+
64+
console.log(`Fixed: ${mismatch.openTag.tag} -> ${mismatch.closeTag.tag} to ${mismatch.openTag.tag}`);
65+
}
66+
67+
fs.writeFileSync(filePath, content);
68+
return true;
69+
}
70+
71+
return false;
72+
}
73+
74+
function processDirectory(dirPath) {
75+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
76+
77+
for (const entry of entries) {
78+
const fullPath = path.join(dirPath, entry.name);
79+
80+
if (entry.isDirectory()) {
81+
processDirectory(fullPath);
82+
} else if (entry.isFile() && entry.name.endsWith('.mdx')) {
83+
fixMismatchedTags(fullPath);
84+
}
85+
}
86+
}
87+
88+
// Process src/pages directory
89+
const pagesDir = path.join(__dirname, 'src', 'pages');
90+
processDirectory(pagesDir);
91+
92+
console.log('Mismatch fixes complete!');

0 commit comments

Comments
 (0)