Delete .github directory
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
import { defineConfig } from 'vitepress';
|
|
||||||
import sidebar from './sidebar.mjs';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
title: 'Sec-Interview',
|
|
||||||
description: '安全面试笔记',
|
|
||||||
base: '/Sec-Interview/',
|
|
||||||
themeConfig: { sidebar }
|
|
||||||
});
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import fs from 'node:fs'
|
|
||||||
import path from 'node:path'
|
|
||||||
|
|
||||||
const summary = fs.readFileSync('SUMMARY.md','utf8')
|
|
||||||
const ROOT = '.'
|
|
||||||
fs.mkdirSync(path.join(ROOT,'.vitepress'),{recursive:true})
|
|
||||||
|
|
||||||
function touch(mdPath){
|
|
||||||
fs.mkdirSync(path.dirname(mdPath),{recursive:true})
|
|
||||||
if (!fs.existsSync(mdPath)) fs.writeFileSync(mdPath,'# \n\n内容待补充。\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===== 生成可折叠 sidebar ===== */
|
|
||||||
const sidebar = []
|
|
||||||
let stack = [{ children: sidebar, level: -1 }] // 栈顶父节点
|
|
||||||
const r = /^(\s*)-\s+\[([^\]]+)\]\(([^)]+)\)/gm
|
|
||||||
let m
|
|
||||||
|
|
||||||
while ((m = r.exec(summary)) !== null) {
|
|
||||||
const [, sp, text, file] = m
|
|
||||||
const level = sp.length / 2
|
|
||||||
const url = '/' + file.replace(/\.md$/,'')
|
|
||||||
|
|
||||||
// 找到父节点
|
|
||||||
while (level <= stack.at(-1).level) stack.pop()
|
|
||||||
const parent = stack.at(-1)
|
|
||||||
|
|
||||||
// 一级目录 → 折叠对象;子项直接 push
|
|
||||||
const node =
|
|
||||||
level === 0
|
|
||||||
? { text, items: [{ text, link: url }], collapsed: true } // 默认折叠
|
|
||||||
: { text, link: url }
|
|
||||||
|
|
||||||
parent.children.push(node)
|
|
||||||
|
|
||||||
// 预留子级挂载点
|
|
||||||
if (level === 0) {
|
|
||||||
node.items = node.items || []
|
|
||||||
stack.push({ children: node.items, level })
|
|
||||||
} else {
|
|
||||||
stack.push({ children: parent.children, level })
|
|
||||||
}
|
|
||||||
|
|
||||||
touch(path.join(ROOT, file))
|
|
||||||
}
|
|
||||||
/* ================================= */
|
|
||||||
|
|
||||||
// frontmatter 处理同上
|
|
||||||
function walk(dir){
|
|
||||||
for (const f of fs.readdirSync(dir)){
|
|
||||||
const full = path.join(dir,f)
|
|
||||||
if (fs.statSync(full).isDirectory()){ walk(full); continue }
|
|
||||||
if (!f.endsWith('.md')) continue
|
|
||||||
const cnt = fs.readFileSync(full,'utf8')
|
|
||||||
if (!cnt.trimStart().startsWith('---'))
|
|
||||||
fs.writeFileSync(full, `---\n---\n${cnt}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
walk(ROOT)
|
|
||||||
|
|
||||||
fs.writeFileSync(path.join(ROOT,'.vitepress','sidebar.mjs'),
|
|
||||||
`export default ${JSON.stringify(sidebar,null,2)}`)
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
name: Build & Deploy VitePress
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
|
|
||||||
- run: echo '{"type":"module","devDependencies":{"vitepress":"^1.0.0"}}' > package.json
|
|
||||||
- run: npm i
|
|
||||||
|
|
||||||
- run: touch .nojekyll
|
|
||||||
|
|
||||||
- run: node .github/scripts/prepare.mjs # 生成 sidebar.mjs
|
|
||||||
|
|
||||||
# 关键替换:直接复制模板,避开 heredoc
|
|
||||||
- run: |
|
|
||||||
mkdir -p .vitepress
|
|
||||||
cp .github/config.template.ts .vitepress/config.ts
|
|
||||||
- run: npx vitepress build .
|
|
||||||
|
|
||||||
- uses: actions/upload-pages-artifact@v3
|
|
||||||
with:
|
|
||||||
path: .vitepress/dist
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment:
|
|
||||||
name: github-pages
|
|
||||||
url: ${{ steps.d.outputs.page_url }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/deploy-pages@v4
|
|
||||||
id: d
|
|
||||||
Reference in New Issue
Block a user