Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
18e0505
wip: custom vitepress theme
Bernankez Oct 22, 2024
9d21a35
wip: vitepress theme sidebar
Bernankez Oct 23, 2024
fefe621
feat: sidebar and motion-reduce
Bernankez Oct 24, 2024
3a6817b
wip: popover
Bernankez Oct 25, 2024
bfad24b
feat: popover component
Bernankez Oct 27, 2024
3f241c7
feat(Popover): extract vNode, add placement prop
Bernankez Oct 28, 2024
1618367
wip: toc
Bernankez Oct 28, 2024
ab770c6
feat: toc for BTocBar
Bernankez Oct 29, 2024
96677a6
wip: nav and toc bar
Bernankez Oct 29, 2024
6d2e185
feat(BLogo): change hover element
Bernankez Oct 29, 2024
d8fa7c6
feat: layout in small screen, wip nav item
Bernankez Oct 30, 2024
6095a0a
fix: build
Bernankez Oct 31, 2024
45b0124
feat: rss support
Bernankez Oct 31, 2024
7647a88
feat: add `target` to social link
Bernankez Oct 31, 2024
d8623de
feat: layout with toc
Bernankez Oct 31, 2024
277f5c4
fix: toc item opacity
Bernankez Oct 31, 2024
6f222e8
fix: sidebar height
Bernankez Oct 31, 2024
9ff26ba
feat: move sidebar toggle button
Bernankez Oct 31, 2024
66a6b50
feat: text selection background color
Bernankez Oct 31, 2024
09d69d6
fix: toc
Bernankez Oct 31, 2024
ae9c620
fix: hide toc if no headers
Bernankez Nov 1, 2024
ad1526a
feat(BLink): add rel prop
Bernankez Nov 1, 2024
257c8b4
feat: do not lock scroll on toc popover
Bernankez Nov 1, 2024
ffb6966
fix: selections
Bernankez Nov 1, 2024
9b3533b
wip: dropdown menu
Bernankez Nov 1, 2024
ff6dc5a
chore: add todo
Bernankez Nov 1, 2024
e8de9f1
fix(Toc): indicator position
Bernankez Nov 20, 2024
a3f4d92
feat: NavDropdown
Bernankez Nov 22, 2024
a33004f
feat: sidebar nav
Bernankez Nov 22, 2024
bae727f
feat: auto hide components when resizing
Bernankez Nov 27, 2024
252196a
wip: layout
Bernankez Nov 28, 2024
ae75cb8
feat(Button): add `class` prop
Bernankez Dec 2, 2024
5fdcd66
wip: BCow
Bernankez Dec 3, 2024
20ae475
fix(BNav): height with border
Bernankez Dec 5, 2024
7f54b95
fix: Layout height
Bernankez Dec 5, 2024
121f071
wip: homepage layout
Bernankez Dec 5, 2024
fdc7a0e
chore: rename `src` to `content`
Bernankez Dec 6, 2024
9754b73
wip: b-content style
Bernankez Dec 6, 2024
9e187a3
chore: disable lint for markdown files
Bernankez Dec 9, 2024
b4e43e7
chore: add `vitepress-plugin-group-icons`
Bernankez Dec 9, 2024
ea6b973
feat: doc style complete
Bernankez Dec 9, 2024
0dc7b73
fix(Toc): left line offset
Bernankez Dec 9, 2024
fe99ba5
feat: 404 page and life game
Bernankez Dec 11, 2024
c0b0a09
feat: comment
Bernankez Dec 11, 2024
4c09a95
feat: doc footer
Bernankez Dec 11, 2024
b5f751e
fix(TocBar): hide if no item
Bernankez Dec 11, 2024
dd66325
feat: edit link
Bernankez Dec 16, 2024
8045ad6
feat: update default values
Bernankez Dec 16, 2024
60b9f65
fix: adjust sidebar width variables for improved layout
Bernankez Dec 16, 2024
0af853c
feat: last updated
Bernankez Dec 16, 2024
b583925
feat: global Badge component
Bernankez Dec 16, 2024
96c3cfb
chore: move all theme components under common dir
Bernankez Dec 16, 2024
6a7c7f6
feat: separate search button and search box
Bernankez Dec 16, 2024
e2f84c2
docs: update todos
Bernankez Dec 16, 2024
f1e3230
wip: blog css-reset
Bernankez Dec 16, 2024
19ee6e9
fix(Sidebar): enhance sidebar item style, remove indent prop
Bernankez Dec 18, 2024
12dde1a
feat: auto generate sidebar by directory structure
Bernankez Dec 18, 2024
6fc988a
wip: global Code Preview component
Bernankez Dec 18, 2024
3984753
feat: global Code Preview component
Bernankez Dec 18, 2024
219d5cd
feat: enhance doc footer color
Bernankez Dec 18, 2024
53a167e
docs: migrate tricks
Bernankez Dec 18, 2024
aa6b19f
feat: enhance gitalk GitHub icon style
Bernankez Dec 18, 2024
f25d5dc
chore: update TODO
Bernankez Dec 18, 2024
f009f77
chore: update TODO
Bernankez Dec 18, 2024
2666344
chore: use dprint to format markdown
Bernankez Dec 19, 2024
0586b03
docs: update tricks
Bernankez Dec 19, 2024
9167ed0
docs: update getting-styles-of-elements-with-display-none
Bernankez Dec 19, 2024
1547c11
chore: sidebar config
Bernankez Dec 19, 2024
e273d5b
fix(CodePreview): enhance margin
Bernankez Dec 19, 2024
8474a91
feat: global collapse component
Bernankez Dec 19, 2024
f93ebb8
feat(Collapse): add desc slot and prop
Bernankez Dec 19, 2024
ef656f0
fix(Collapse): remove padding top for content
Bernankez Dec 19, 2024
8d216e1
docs: migrate front-end posts
Bernankez Dec 19, 2024
5a100fd
docs: migrate posts under others
Bernankez Dec 19, 2024
92b408e
chore: fix tsconfig
Bernankez Dec 19, 2024
7284aea
fix(Gitalk): reloading comments when switching pages
Bernankez Dec 19, 2024
4114776
fix(Gitalk): enhance styles
Bernankez Dec 19, 2024
3c0dca4
fix(Collapse): cursor style
Bernankez Dec 19, 2024
b2cd55a
fix(SidebarItem): opacity
Bernankez Dec 19, 2024
dc5a6f1
docs: migrate stereotyped-writings
Bernankez Dec 19, 2024
940120a
docs: update README
Bernankez Dec 19, 2024
3c63c78
chore: fix assets path
Bernankez Dec 19, 2024
7517600
wip: search
Bernankez Dec 19, 2024
8f79e51
fix(SidebarItem): style
Bernankez Dec 20, 2024
4c958c6
chore: organize directory structure
Bernankez Dec 20, 2024
8065274
feat: add posts
Bernankez Dec 20, 2024
039a28a
wip: LocalSearchBox style
Bernankez Dec 20, 2024
629b665
fix: backdrop background color in dark mode
Bernankez Dec 24, 2024
42a506e
feat: enhance search box style
Bernankez Dec 24, 2024
5961e89
chore: z-index
Bernankez Dec 24, 2024
a8e77a4
chore: update search box z-index values for improved layering
Bernankez Dec 24, 2024
12a5031
feat(BContent): improve toggle expand sidebar button position
Bernankez Dec 25, 2024
94ea7fc
feat: back to top and toggle theme floating buttons
Bernankez Dec 25, 2024
c9c5ec1
feat: shiki twoslash
Bernankez Dec 25, 2024
85bdcff
feat: add twoslash for some posts
Bernankez Dec 25, 2024
feb2f80
feat: homepage lood around
Bernankez Dec 25, 2024
462a33d
feat: add blog
Bernankez Feb 6, 2025
614656e
fix: blog url
Bernankez Feb 7, 2025
03b4494
feat: enhance floating buttons style
Bernankez Feb 7, 2025
bf875da
fix(BSidebar): component key
Bernankez Feb 7, 2025
c5d6957
fix(BCodePreview): tab text color
Bernankez Feb 7, 2025
7230148
fix: z-index for floating buttons
Bernankez Feb 7, 2025
f7983d0
feat: cow model
Bernankez Feb 7, 2025
def1f59
fix(BSidebarItem): component key
Bernankez Feb 7, 2025
e314584
feat: homepage
Bernankez Feb 10, 2025
fbce63f
docs: update README
Bernankez Feb 10, 2025
43c85f5
chore: fix zdog import
Bernankez Feb 10, 2025
1bfbfeb
chore: bump deps
Bernankez Feb 10, 2025
b5c622a
fix: homepage layout
Bernankez Feb 10, 2025
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
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc.cjs

This file was deleted.

32 changes: 23 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
*.iml
dist
dist-ssr
*.local

# Editor directories and files
.idea
*.log*
.nuxt
.vscode
.DS_Store
coverage
dist
sw.*
.env
.output
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# vitepress
.vitepress/dist
.vitepress/cache
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

274 changes: 274 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
import type { _DirConfig, NavItemWithLink, SidebarItem, ThemeConfig } from "../theme/types";
import { readdirSync, readFileSync } from "node:fs";
import { basename, parse, relative, resolve } from "node:path";
import process from "node:process";
import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { parseYAML } from "confbox";
import matter from "gray-matter";
import UnoCSS from "unocss/vite";
import Icons from "unplugin-icons/vite";
import DevTools from "vite-plugin-vue-devtools";
import { defineConfigWithTheme } from "vitepress";
import { groupIconMdPlugin, groupIconVitePlugin } from "vitepress-plugin-group-icons";
import { RssPlugin } from "vitepress-plugin-rss";

// https://vitepress.dev/reference/site-config
export default async () => {
return defineConfigWithTheme<ThemeConfig>({
lang: "zh-CN",
title: "科科Cole",
titleTemplate: ":title · 科科Cole",
description: "Cole.blog",
head: [
["link", { rel: "icon", href: "/favicon.ico" }],
],
srcDir: "content",
cleanUrls: true,
lastUpdated: true,
ignoreDeadLinks: true,
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: "/logo.webp",
logoOnHover: "/logo-wink.webp",
socialLinks: [
{ icon: "rss", link: "/feed.xml", ariaLabel: "RSS", title: "RSS", target: "_self" },
{ icon: "github", link: "https://github.com/Bernankez/blog", ariaLabel: "GitHub", title: "GitHub" },
{ icon: "home", link: "https://keke.cc", ariaLabel: "Home", title: "Home" },
],
nav: [
generateNavItem(resolve(process.cwd(), "content", "tech")),
generateNavItem(resolve(process.cwd(), "content", "blog")),
generateNavItem(resolve(process.cwd(), "content", "stereotyped-writing")),
],
sidebar: {
"/tech/": [
...generateSidebarItem(resolve(process.cwd(), "content", "tech"), {
indentFromLevel: 0,
}).items!,
],
"/blog/": [
...generateSidebarItem(resolve(process.cwd(), "content", "blog")).items!,
],
"/stereotyped-writing/": [
...generateSidebarItem(resolve(process.cwd(), "content", "stereotyped-writing"), {
indentFromLevel: 0,
collapsed: false,
}).items!,
],
},
toc: {
title: "页面导航",
},
notFound: {
homeButton: "返回首页",
lifeGame: {
play: "播放",
pause: "暂停",
prevStep: "上一步",
nextStep: "下一步",
reset: "重置",
},
},
comment: {
gitalk: {
clientID: "40827213be1939c08aba",
clientSecret: "40da0008fb88ccd7c81fb004c1292543e66998c9",
repo: "blog-comment",
owner: "Bernankez",
admin: ["Bernankez"],
},
},
docFooter: {
prev: "上一页",
next: "下一页",
},
editLink: {
text: "在GitHub上编辑",
pattern: "https://github.com/bernankez/blog/edit/master/content/:path",
},
lastUpdated: {
text: "上次更新于",
formatOptions: {
dateStyle: "full",
timeStyle: "medium",
},
},
search: {
provider: "local",
options: {
locales: {
root: {
translations: {
button: {
buttonText: "搜索文档",
buttonAriaLabel: "搜索文档",
},
modal: {
displayDetails: "显示预览",
resetButtonTitle: "清空",
backButtonTitle: "返回",
footer: {
selectText: "选择",
navigateText: "切换",
closeText: "关闭",
},
noResultsText: "无法找到相关结果",
},
},
},
},
},
},
// search: {
// provider: "algolia",
// options: {
// apiKey: "f3c4b78009a6ed7d455512effbadf33a",
// appId: "4U4R8B36SX",
// indexName: "keke",
// },
// },
},
markdown: {
image: {
lazyLoading: true,
},
codeTransformers: [
transformerTwoslash(),
],
config(md) {
md.use(groupIconMdPlugin);
},
},
vite: {
plugins: [
vueJsx(),
UnoCSS(),
Icons({
scale: 1.2,
}),
groupIconVitePlugin(),
RssPlugin({
title: "科科Cole",
baseUrl: "https://blog.keke.cc",
copyright: "Copyright ©️ 2023-PRESENT 科科Cole",
icon: false,
language: "zh-CN",
author: {
name: "科科Cole",
email: "bernankeic@gmail.com",
link: "https://blog.keke.cc",
},
filename: "feed.xml",
ignoreHome: true,
ignorePublish: false,
}),
DevTools(),
],
},
});
};

const _DIR_NAME = ["_dir.yaml", "_dir.yml"];

interface GenerateSidebarItemOptions extends SidebarItem {
base?: string;
}

function generateSidebarItem(path: string, options?: GenerateSidebarItemOptions): SidebarItem {
const { base = "", ...restOptions } = options || {};
const files = readdirSync(path, { withFileTypes: true });
const sortedFiles = files
.filter((file) => {
if (file.isDirectory()) {
return true;
}
if (_DIR_NAME.includes(file.name)) {
return true;
}
const ext = parse(file.name).ext;
return ext === ".md";
})
.toSorted((a, b) => a.name.localeCompare(b.name));

const sidebarItem: SidebarItem = {
...restOptions,
};

const directoryName = basename(path);
const _dir = files.find(file => file.name === "_dir.yml" || file.name === "_dir.yaml");
if (_dir?.isFile()) {
const _dirFile = readFileSync(resolve(path, _dir.name), "utf-8");
const config = parseYAML<_DirConfig>(_dirFile);
sidebarItem.text = config.title;
} else {
sidebarItem.text = pascalCase(directoryName);
}

sidebarItem.items = sortedFiles.map((file) => {
if (file.isDirectory()) {
return generateSidebarItem(resolve(path, file.name), {
base: `${base ? `${base}/${directoryName}` : `/${directoryName}`}`,
...restOptions,
});
}
if (_DIR_NAME.includes(file.name)) {
return undefined;
}
const fileContent = readFileSync(resolve(path, file.name), "utf-8");
const { data = {} } = matter(fileContent);
return {
text: data.title || pascalCase(extractName(file.name)),
link: `${base ? `${base}/${directoryName}` : `/${directoryName}`}/${extractName(file.name)}`,
};
}).filter(item => item !== undefined);

return sidebarItem;
}

function generateNavItem(path: string) {
const navItem: NavItemWithLink = {} as NavItemWithLink;
const directoryName = basename(path);
navItem.activeMatch = `/${directoryName}/`;
const files = readdirSync(path, { withFileTypes: true });
const _dir = files.find(file => file.name === "_dir.yml" || file.name === "_dir.yaml");
if (_dir?.isFile()) {
const _dirFile = readFileSync(resolve(path, _dir.name), "utf-8");
const config = parseYAML<_DirConfig>(_dirFile);
navItem.text = config.title;
} else {
navItem.text = pascalCase(directoryName);
}
const md = getFirstMdFile(path);
if (md) {
navItem.link = `/${directoryName}/${relative(path, md.path)}/${extractName(md.filename)}`;
}
return navItem;
}

function getFirstMdFile(path: string) {
// 递归找到目录下第一个md文件
const files = readdirSync(path, { withFileTypes: true });
for (const file of files) {
if (file.isDirectory()) {
return getFirstMdFile(resolve(path, file.name));
}
if (file.name === "_dir.yml" || file.name === "_dir.yaml") {
continue;
}
if (file.name.endsWith(".md")) {
return {
path,
filename: file.name,
};
}
}
}

function extractName(filename: string) {
return parse(filename).name;
}

function pascalCase(str: string) {
return str.replace(/-/g, " ").replace(/\b\w/g, char => char.toUpperCase());
}
13 changes: 13 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { EnhanceAppContext } from "vitepress";
import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
import theme from "../../theme";
import "virtual:group-icons.css";
import "@shikijs/vitepress-twoslash/style.css";
import "./shiki-twoslash.css";

export default {
extends: theme,
enhanceApp({ app }: EnhanceAppContext) {
app.use(TwoslashFloatingVue as any);
},
};
18 changes: 18 additions & 0 deletions .vitepress/theme/shiki-twoslash.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** Shiki Twoslash popup */
:root {
--twoslash-popup-bg: hsl(var(--background));
--twoslash-popup-color: hsl(var(--foreground));
--twoslash-docs-color: hsl(var(--foreground));
--twoslash-docs-font: var(--b-font-family-base);
--twoslash-code-font: var(--b-font-family-mono);
--twoslash-code-size: var(--b-code-font-size);
--twoslash-underline-color: #8888;
--twoslash-border-color: hsl(var(--border));
--twoslash-cursor-color: hsl(var(--primary));
--twoslash-matched-color: hsl(var(--primary));
--twoslash-unmatched-color: hsl(var(--muted-foreground));
}

.v-popper--theme-twoslash {
z-index: var(--b-popover-z-index);
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eslint.quiet": true
}
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

Loading