Skip to content

Commit 34af6d8

Browse files
committed
fix: update
1 parent cbe0753 commit 34af6d8

38 files changed

+1322
-2763
lines changed

.editorconfig

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
16
[*]
2-
charset=utf-8
3-
end_of_line=lf
4-
insert_final_newline=true
5-
indent_style=space
6-
indent_size=4
7-
trim_trailing_whitespace=true
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
[*.{yml,yaml,md}]
15+
indent_size = 2

.eslintrc.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: GH Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
pages:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: '18'
18+
19+
- run: npm audit --audit-level=high
20+
- run: npm ci
21+
- run: npm run build
22+
23+
- name: Deploy
24+
uses: peaceiris/actions-gh-pages@v3
25+
with:
26+
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
publish_dir: ./docs

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
docs

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import Path from 'path'
33
import MDIT from 'markdown-it'
44
import MA from 'markdown-it-anchor'
55

6+
const source = process.argv[2] || 'src'
7+
const target = process.argv[3] || 'docs'
8+
69
const MD = MDIT('commonmark', {
710
html: true,
811
linkify: true,
@@ -51,19 +54,31 @@ const wrapHtml = (main: string, title: string = '') => `<!-- autogenerated -->
5154
</html>
5255
`
5356

54-
;(async () => {
55-
await Promise.all(((await readDirR('docs')).filter(f => f.endsWith('.html')).map(async file => {
56-
const text = String(await fs.readFile(file))
57-
if (text.startsWith('<!-- autogenerated -->')) return await fs.unlink(file)
58-
})))
57+
const transforms: { [k: string]: (text: string, path: string) => [text: string, path: string] } = {
58+
'.md': (text, path) => {
59+
path = target + path.slice(source.length, -3)
60+
const content = wrapHtml(MD.render(text))
61+
return [content, path + '.html']
62+
},
63+
'*': (text, path) => {
64+
path = target + path.slice(source.length)
65+
return [text, path]
66+
},
67+
}
68+
const applyTransform = (text: string, path: string) => {
69+
for (const [ext, transform] of Object.entries(transforms)) {
70+
if (path.endsWith(ext) || ext === '*') return transform(text, path)
71+
}
72+
return []
73+
}
5974

60-
await Promise.all(((await readDirR('md')).map(async file => {
75+
;(async () => {
76+
await Promise.all(((await readDirR(source)).map(async file => {
6177
const text = String(await fs.readFile(file))
62-
const name = file.slice(3, -3)
63-
const html = wrapHtml(MD.render(text), Path.basename(name))
64-
const filepath = 'docs/' + name + '.html'
65-
await fs.mkdir(Path.dirname(filepath), { recursive: true })
66-
return await fs.writeFile(filepath, html)
78+
const [newText, newFile] = applyTransform(text, file)
79+
if (!newText) return
80+
await fs.mkdir(Path.dirname(newFile), { recursive: true })
81+
return await fs.writeFile(newFile, newText)
6782
})))
6883
})().catch(reason => {
6984
console.error(reason)

docs/blog/index.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/blog/visual-kb-interface.html

Lines changed: 0 additions & 96 deletions
This file was deleted.

docs/cards/index.html

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)