第三次重构个人博客(基于 Vitepress)

51 天前
 Justin3go

原文内容:justin3go.com

摘要:

笔者在这篇文章中记录了自己第三次重构个人博客的过程,基于 Vitepress 进行了一系列的改进和优化。自 2022 年初开始使用 Vitepress 搭建博客,随着版本的更新,笔者逐渐感受到原有风格的不适,决定进行重新设计。本次重构的主要内容包括:

  1. 首页设计:采用简单的博客分页列表,利用 createContentLoader 提取文章摘要等信息。
  2. 部署与域名管理:将博客从 Github Pages 迁移至 Cloudflare Pages ,并更改 DNS 服务器。
  3. 国际化支持:实现 Vitepress 和评论系统 Giscus 的国际化,支持中英双语。
  4. 内容迁移:对博客文章进行迁移,生成摘要和标签,确保旧路径的兼容性以避免外链失效。
  5. 优化用户体验:自定义字体并进行预加载,提升页面加载速度。

通过这些调整,笔者希望博客不仅在内容上丰富,同时在视觉和使用体验上也能给读者带来更好的感受。最终,笔者强调了博客设计对写作心情的重要性,认为整理环境能够促进创作灵感的流动。

博客网站是开源的: https://github.com/Justin3go/justin3go.com

3148 次点击
所在节点    分享发现
54 条回复
subframe75361
50 天前
@ThomasChan 那用啥,flexsearch ?
ThomasChan
50 天前
@subframe75361 就还是 minisearch ,我说的研究的意思是指看了下 vitepress 源码怎么使用 minisearch 的,最后发现是分词的配置问题,在 vitepress 里像下边这样配置就可以了

```js
...
export default defineConfig({
...
themeConfig: {
search: {
options: {
miniSearch: {
options: {
tokenize: (term) => {
if (typeof term === 'string') term = term.toLowerCase();
// @ts-ignore
const segmenter = Intl.Segmenter && new Intl.Segmenter("zh", { granularity: "word" });
if (!segmenter) return [term];
const tokens = [];
for (const seg of segmenter.segment(term)) {
// @ts-ignore
tokens.push(seg.segment);
}
return tokens;
},
},
searchOptions: {
combineWith: 'AND', // important for search chinese
processTerm: (term) => {
if (typeof term === 'string') term = term.toLowerCase();
// @ts-ignore
const segmenter = Intl.Segmenter && new Intl.Segmenter("zh", { granularity: "word" });
if (!segmenter) return term;
const tokens = [];
for (const seg of segmenter.segment(term)) {
// @ts-ignore
tokens.push(seg.segment);
}
return tokens;
},
},
},
},
},
},
...
});
```
nagisaushio
50 天前
@Justin3go 中文字体建议按汉字词频做字体切分
Justin3go
50 天前
@nagisaushio #43 了解到了新知识,谢谢!❤️
1rv013c6aiWPGt24
50 天前
看看我的 simple blog
yuanj.top
Justin3go
50 天前
@UncleCAT4 #45
Tink
50 天前
laoertongzhi
50 天前
@Justin3go #34 非常感谢!
Justin3go
50 天前
@Tink #47 搞基男
1rv013c6aiWPGt24
50 天前
@Tink 你这个吊,
dif
49 天前
@UncleCAT4 敦煌老乡?
1rv013c6aiWPGt24
49 天前
@dif 怎么说?哥们也是敦煌的?
dif
43 天前
@UncleCAT4 必须的~~
1rv013c6aiWPGt24
43 天前
@dif 认识一下?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1061365

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX