diff --git a/package.json b/package.json
index ac45d44..fe8f8af 100644
--- a/package.json
+++ b/package.json
@@ -14,10 +14,13 @@
"dependencies": {
"@dimforge/rapier2d": "^0.11.2",
"@tldraw/tldraw": "2.0.2",
+ "@types/markdown-it": "^14.1.1",
"@vercel/analytics": "^1.2.2",
+ "gray-matter": "^4.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-router-dom": "^6.22.3"
+ "react-router-dom": "^6.22.3",
+ "vite-plugin-md": "^0.21.5"
},
"devDependencies": {
"@biomejs/biome": "1.4.1",
diff --git a/src/App.tsx b/src/App.tsx
index 0885a60..ed14069 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -10,6 +10,7 @@ import { useCanvas } from "@/hooks/useCanvas"
import { createShapes } from "@/utils";
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { Contact } from "@/components/Contact";
+import { Post } from '@/components/Post';
inject();
ReactDOM.createRoot(document.getElementById("root")!).render(
Alongside my independent work I am a researcher at Block Science building{' '} - knowledge organisation infrastructure and at ECSA working on{' '} - computational media. I am also part of the nascent Liberatory Computing{' '} - collective and a co-organiser of the OCWG. + knowledge organisation infrastructure and an engineer-in-residence at tldraw. I am also part of the nascent Liberatory Computing{' '} + collective, occasional collaborator with ECSA and a co-organiser of the OCWG.
';
+md.renderer.rules.image = (tokens, idx, options, env, self) => {
+ const token = tokens[idx];
+ const src = token.attrGet('src');
+ const alt = token.content;
+ return ``;
+};
+
+export function markdownToHtml(content: string): string {
+ return md.render(content);
+}
\ No newline at end of file
diff --git a/tsconfig.node.json b/tsconfig.node.json
index 42872c5..bf67dd4 100644
--- a/tsconfig.node.json
+++ b/tsconfig.node.json
@@ -1,10 +1,10 @@
{
- "compilerOptions": {
- "composite": true,
- "skipLibCheck": true,
- "module": "ESNext",
- "moduleResolution": "bundler",
- "allowSyntheticDefaultImports": true
- },
- "include": ["vite.config.ts"]
+ "compilerOptions": {
+ "composite": true,
+ "skipLibCheck": true,
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "allowSyntheticDefaultImports": true
+ },
+ "include": ["vite.config.ts", "src/utils/*"]
}
diff --git a/vite.config.ts b/vite.config.ts
index 9b55a11..77bb315 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,13 +1,29 @@
-import { defineConfig } from 'vite'
+import { defineConfig, Plugin } from 'vite'
import react from '@vitejs/plugin-react'
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
+import matter from 'gray-matter';
+import { markdownToHtml } from './src/utils/markdownToHtml';
+
+const markdownPlugin: Plugin = {
+ name: 'markdown-plugin',
+ enforce: 'pre',
+ transform(code, id) {
+ if (id.endsWith('.md')) {
+ const { data, content } = matter(code);
+ const html = markdownToHtml(content);
+ const jsonContent = JSON.stringify({ ...data, html });
+ return `export default ${jsonContent};`;
+ }
+ },
+};
export default defineConfig({
plugins: [
react(),
wasm(),
- topLevelAwait()
+ topLevelAwait(),
+ markdownPlugin
],
build: {
sourcemap: true, // Enable source maps for production