Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Linhieng committed Mar 27, 2024
0 parents commit c4699a5
Show file tree
Hide file tree
Showing 15 changed files with 1,636 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
#
name: Deploy VitePress site to Pages

on:
# 在针对 `main` 分支的推送上运行。如果你
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
push:
branches: [main]

# 允许你从 Actions 选项卡手动运行此工作流程
workflow_dispatch:

# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false

jobs:
# 构建工作
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# with:
# fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消注释
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm # 或 pnpm / yarn
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: npm ci # 或 pnpm install / yarn install / bun install
- name: Build with VitePress
run: npm run docs:build --base /Lim-note-interview/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist

# 部署工作
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.vitepress/cache
.vitepress/dist
package-lock.json
141 changes: 141 additions & 0 deletions .vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { defineConfig } from 'vitepress'
import fs from 'node:fs'
import { join, sep, basename } from 'path'
import { normalize } from 'node:path'

const docsRoot = './docs'

/** 侧边栏中的一级标题,可能需要更改名称 */
const basenameMapping = (_basename) => {
_basename = basename(_basename, '.md')
switch (_basename) {
case 'debug': return '个人遇到的问题以及解决方案'

case 'misc': return '其他杂项'

case 'base': return '概览'

case 'my': return '个人整理'

default: return _basename
}
}
function isFile(docsDir) {
const stat = fs.statSync(docsDir)
return stat.isFile()
}
function splitPath(path) {
return path.split(sep)
}
function formatLink(link) {
return '/' + normalize(link).split(sep).join('/')
}
/**
*
* @param {string} rootPath
* @returns {MarkdownList}
*/
function dfs(rootPath) {
/** @type {MarkdownList} */
const markdownList = []
const stack = [rootPath]
const hadVisited = [rootPath]
let curNode, children
while (stack.length !== 0) {
curNode = stack.pop()
if (isFile(curNode)) {
if (curNode.endsWith('.md')) {
markdownList.push({
splitPath: splitPath(curNode),
linkPath: formatLink(curNode)
})
}
continue
}
children = fs.readdirSync(curNode).map(v => join(curNode, v))
for (const child of children) {
if (!hadVisited.includes(child)) {
stack.push(curNode, child)
hadVisited.push(child)
break
}
}
}
return markdownList
}

/**
*
* @param {MarkdownList} markdownList
* @returns
*/
function generateSideBar(markdownList) {
const sidebar = [{
text: '',
}]
const sideBarItems = []
const textMap = new Map()

markdownList.forEach(({ splitPath, linkPath }) => {
const firstFolder = splitPath[1]
if (splitPath.length === 2) {
// 对于单个文件,没有文件夹的情况,直接展示,不需要拥有子项
textMap.set(firstFolder, linkPath)
return
}

if (textMap.has(firstFolder)) {
const items = textMap.get(firstFolder)
textMap.set(firstFolder, [...items, linkPath])
} else {
textMap.set(firstFolder, [linkPath])
}
})
for (const [text, links] of textMap) {
if (links instanceof Array) {
const items = links.map(link => ({
text: basenameMapping(link),
link
}))
sideBarItems.push({
text: basenameMapping(text),
items
})
} else {
// 单标签,无下拉
sideBarItems.push({
text: basenameMapping(text),
link: links
})
}
}
sidebar[0].items = sideBarItems
return sidebar
}
const markdownList = dfs(docsRoot)
const sidebar = generateSideBar(markdownList)


// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "linhieng 整理的面经/前端基础",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '主页', link: '/' },
{ text: '面经', link: '/README' },
{ text: 'web 笔记', link: 'https://blog.linhieng.com/Lim-note-web' },
{ text: 'vscode 笔记', link: 'https://blog.linhieng.com/Lim-note-vscode' },
],

sidebar,

socialLinks: [
{ icon: 'github', link: 'https://github.com/linhieng/lim-note-interview' }
],

search: {
provider: 'local'
}
}
})
6 changes: 6 additions & 0 deletions .vitepress/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type MarkdownList = Array<{
/** 对路径进行分割,并存储在数组中,比如 [docs, debug, index.md] */
splitPath: string[],
/** 链接路径,比如 docs/debug/index.md */
linkPath: string,
}>
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 面经

既是八股文,同时也是基础!

面经/基础网站:

- [web前端面试 - 面试官系列](https://vue3js.cn/interview/)
- [大厂面试每日一题](https://q.shanyue.tech/)
- [木易杨前端进阶](https://muyiy.cn/)
- [前端进阶之旅](https://interview.poetries.top/) 付费,但免费的已经够看了
- [前端笔记-舒彬琪的前端笔记](http://vue.cnsbq.com/)
- [被删的前端游乐场](http://godbasin.com/)
4 changes: 4 additions & 0 deletions docs/css/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# css 面经

- [2022高频前端面试题——CSS篇](https://juejin.cn/post/7098689890933538853)
- [CSS 各种布局以及相关概念](https://juejin.cn/post/6936913689115099143)
Loading

0 comments on commit c4699a5

Please sign in to comment.