Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 添加 vitepress 支持 #11

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/page.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Vitepress Deployment

on:
push:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: yarn install

- name: Build
run: yarn run docs:build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.vitepress/dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.vitepress/dist
.vitepress/cache
39 changes: 39 additions & 0 deletions .vitepress/autoNavgation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import fs from 'fs'
import type { DefaultTheme } from 'vitepress'

export const autoNavigation = (baseUrl: string): DefaultTheme.Sidebar => {
const walk = (dir: string, callback: (path: string) => void) => {
const files = fs.readdirSync(dir)
files.forEach(file => {
const path = `${dir}/${file}`
const stat = fs.statSync(path)
if (stat.isDirectory()) {
walk(path, callback)
} else {
callback(path)
}
})
}
let sidebar: DefaultTheme.Sidebar = [];
walk(baseUrl, (path) => {
const relativePath = path.replace(/\.md$/, '')
const parts = relativePath.split('/')
parts.splice(0, 2)
let current = sidebar
parts.forEach((part, index) => {
const find = current.find(item => item.text === part)
if (find) {
current = find.items || []
} else {
const item = {
text: part,
link: relativePath.replace('./', '/'),
items: []
}
current.push(item)
current = item.items
}
})
})
return sidebar
}
24 changes: 24 additions & 0 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'vitepress'
import { autoNavigation } from './autoNavgation.ts'

const sidebar = autoNavigation('./cookbook');
// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "Cook Like HOC",
description: "像老乡鸡那样做饭",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
],

sidebar: sidebar,

socialLinks: [
{ icon: 'github', link: 'https://github.com/soilzhu/cooklikehoc' }
]
},

// 临时处理,须在每个菜品分类文件夹下手动创建 index.md 文件
ignoreDeadLinks: true
})
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

# 像老乡鸡那样做饭

- [蒸菜](/蒸菜)
- [炒菜](/炒菜)
- [炖菜](/炖菜)
- [砂锅菜](/砂锅菜)
- [烫菜](/烫菜)
- [煮锅](/煮锅)
- [卤菜](/卤菜)
- [凉拌](/凉拌)
- [早餐](/早餐)
- [饮品](/饮品)
- [汤](/汤)
- [配料](/配料)(主要来自老乡鸡自有中央厨房,但其详细成分与配比老乡鸡官方未公布)
- [蒸菜](/cookbook/蒸菜)
- [炒菜](/cookbook/炒菜)
- [炖菜](/cookbook/炖菜)
- [砂锅菜](/cookbook/砂锅菜)
- [烫菜](/cookbook/烫菜)
- [煮锅](/cookbook/煮锅)
- [卤菜](/cookbook/卤菜)
- [凉拌](/cookbook/凉拌)
- [早餐](/cookbook/早餐)
- [饮品](/cookbook/饮品)
- [汤](/cookbook/汤)
- [配料](/cookbook/配料)(主要来自老乡鸡自有中央厨房,但其详细成分与配比老乡鸡官方未公布)

《老乡鸡菜品溯源报告》中公布的所有菜品已经全部录入完,欢迎大家查阅和补充。

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home

hero:
name: "Cook Like HOC"
text: "像老乡鸡那样做饭"
tagline: 来自《老乡鸡菜品溯源报告》。
actions:
- theme: brand
text: 做饭!
link: /readme_web.md

---

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "cook-like-hoc",
"version": "1.0.0",
"main": "index.js",
"license": "UNLICENSED",
"devDependencies": {
"@types/node": "^20.12.7",
"vitepress": "^1.1.0",
"vitepress-auto-navigation": "^0.0.4"
},
"scripts": {
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview"
}
}
14 changes: 14 additions & 0 deletions readme_web.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
![pic](/banner.png)

# 像老乡鸡那样做饭

《老乡鸡菜品溯源报告》中公布的所有菜品已经全部录入完,欢迎大家查阅和补充。

文字超大段copy自[《老乡鸡菜品溯源报告》](https://www.lxjchina.com.cn/display.asp?id=4226),有编辑与整理

指路隔壁 [How To Cook](https://cook.aiurs.co/)

至于为什么仓库名要叫CookLikeHOC,因为直接写Laoxiangji大概不方便阅读,而Home Original Chicken是china daily报道中所使用的老乡鸡的英文名,故简写成HOC。


![pic](/logo.png)
Loading