Skip to content

Commit

Permalink
Introduce basic page builder
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Sep 3, 2024
1 parent 640fed9 commit d1ca81f
Show file tree
Hide file tree
Showing 9 changed files with 1,086 additions and 31 deletions.
5 changes: 3 additions & 2 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
node_modules/
dist/

11 changes: 0 additions & 11 deletions app/index.html

This file was deleted.

37 changes: 37 additions & 0 deletions app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { renderToStaticMarkup } from 'react-dom/server';
import { App } from './src/App';
import { readFile, rmdir, mkdir, writeFile, readdir } from 'fs/promises';
import { remark } from 'remark';
import html from 'remark-html';

let markdown_files = await readdir('../ensips');
const files = markdown_files.map(x => `../ensips/${x}`);

// delete the dist folder
try {
await rmdir('./dist', { recursive: true })
} catch (e) {
console.log(e);
}

await mkdir('./dist');

for (const file of files) {
const fileData = await readFile(file, 'utf8');

const result = await remark().use(html).process(fileData);

const x = renderToStaticMarkup(<App markdown={result.value.toString()} />);

// write to file
await writeFile(`./dist/${file.split('/').pop()?.replace('.md', '.html')}`, x);
}

const static_files = ['./public/index.css'];

for (const file of static_files) {
const fileData = await readFile(file, 'utf8');

// write to file
await writeFile(`./dist/${file.split('/').pop()}`, fileData);
}
35 changes: 19 additions & 16 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "vite build",
"dev": "vite"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^5.5.4",
"vite": "^5.4.3"
}
"type": "module",
"scripts": {
"build": "tsx index.tsx",
"preview": "pnpm run build && pnpm vite preview"
},
"dependencies": {
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"remark": "^15.0.1",
"remark-html": "^16.0.1",
"tsx": "^4.19.0",
"typescript": "^5.5.4",
"vite": "^5.4.3"
},
"devDependencies": {
"@types/node": "^22.5.2"
}
}
Loading

0 comments on commit d1ca81f

Please sign in to comment.