-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,086 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
dist | ||
node_modules/ | ||
dist/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Oops, something went wrong.