GithubHelp home page GithubHelp logo

atqq / sugar-blog Goto Github PK

View Code? Open in Web Editor NEW
269.0 7.0 52.0 10.72 MB

✍️📚我写博客的地方🤪🤪🤪记录随笔与学习笔记,仓库包含:博客内容,博客主题、博客模板、vitepress离线全文搜索插件、VitePress RSS 支持插件;a blog theme use vitepress

Home Page: https://sugarat.top

License: MIT License

JavaScript 1.82% TypeScript 42.18% SCSS 8.77% Vue 42.02% CSS 5.22%
blog vitepress vitepress-blog vitepress-theme

sugar-blog's Introduction

粥里有勺糖

你的指尖,拥有改变世界的力量

博客主题:@sugarat/theme

code style

仓库介绍

这是一个 monorepo 仓库,目前有如下四个部分

快速创建博客模板

支持多种包管理工具

# With PNPM:
pnpm create @sugarat/theme

# With NPM:
npm create @sugarat/theme@latest

# With Yarn:
yarn create @sugarat/theme

# With Bun
bun create @sugarat/theme

运行本项目

这是一个 monorepo 仓库,博客基于vitepress搭建,运行前需先安装依赖,构建主题包

① 先安装 pnpm

npm i -g pnpm
# 安装依赖
pnpm install

② 构建依赖包的npm包

pnpm buildlib

③ 运行

# 运行博客
pnpm dev

# 运行主题包文档
pnpm dev:theme

📝关于内容

大前端开发相关知识,包含但不限于前端

记录面试中所遇的问题,并整理相关知识点,分模块进行了梳理

21年毕业,目前就职于美团,热爱大前端开发技术

热爱开源,乐于分享

图片

🔗个人相关链接

☎️联系我

如对博客内容,知识,排版等有疑问或者建议,欢迎邮件和我联系

邮箱:[email protected]

公众号

☕赞赏

微信 微信赞赏 支付宝

Star History

Star History Chart

Stargazers over time

Stargazers over time

Project Status

status

Contributors

Thanks to all the contributors!

Made with contrib.rocks.

sugar-blog's People

Contributors

1gcat avatar admin8756 avatar atqq avatar augusttty avatar cyrilbois avatar deer404 avatar hacxy avatar itcatplayit avatar jiapy97 avatar qiaofugui avatar qiu-jun avatar rabbit937 avatar ymriri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sugar-blog's Issues

文章frontMatter使用本地cover,部署后在index页面图片路径错误

image
  1. 使用默认cover,自动提取第一张作为封面图,博客内图片地址是/images/f1ce52f08ad9864f3bc30d2c2f9b7336.jpeg
  2. 文章的图片地址build后会变成/assets/f1ce52f08ad9864f3bc30d2c2f9b7336.dO6K0w_d.jpeg,但index封面图还是/images/f1ce52f08ad9864f3bc30d2c2f9b7336.jpeg

不确定vitepress编译后的静态文件目录是否都在assets,如果是的话修复就比较简单,直接判断是否是项目静态文件,如果是的话直接把路径强行变成/assets/xxx
不确定是否有其他影响,有什么其他配置可以更优雅的解决这个问题更好~

打包会出现问题

'pagefind' is not recognized as an internal or external command,
operable program or batch file.
build error:
Error: Command failed: npx pagefind --source docs.vitepress\dist --exclude-selectors "div.aside, a.header-anchor"
at checkExecSyncError (node:child_process:885:11)
at execSync (node:child_process:957:15)
at vitepressConfig.buildEnd (F:\vitepress\my-blog\node_modules.pnpm@[email protected][email protected][email protected]\node_modules@sugarat\theme\node.js:329:49)
at build (file:///F:/vitepress/my-blog/node_modules/.pnpm/vitepress@1.0.0-beta.5_@algolia[email protected][email protected][email protected]/node_modules/vitepress/dist/node/serve-d0f912b9.js:48768:59)
 ELIFECYCLE  Command failed with exit code 1.
大佬有空解决一下

标签bug

复现步骤:

  1. 选个标签,如 javascript,url变成了:/?tag=javascript&type=warning
  2. 点击头部VPNavBarTitle区域,url去掉了标签,url变成了: /
  3. 右边的BlogHomeTags上方没清除标签,而且中间文章列表没变成全部列表,还停留在javascript标签相关的文章列表。

帮忙看着这个报错,这个路径下没有node.js文件

failed to load config from /Users/liuguisheng/code/github/sugar-blog/packages/blogpress/.vitepress/config.ts
failed to start server. error:
Error: Cannot find module '/Users/liuguisheng/code/github/sugar-blog/packages/blogpress/node_modules/@sugarat/theme/node.js'
at createEsmNotFoundErr (node:internal/modules/cjs/loader:960:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:953:15)
at resolveExports (node:internal/modules/cjs/loader:482:14)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/liuguisheng/code/github/sugar-blog/packages/blogpress/.vitepress/config.ts:35:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)

升级主题后,无法运行

复现步骤:

pnpm up @sugarat/theme
pnpm add vitepress@latest

package.json

{
  "name": "vitepress-blog",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "vitepress dev docs",
    "build": "vitepress build docs",
    "serve": "vitepress serve docs"
  },
  "dependencies": {
    "@element-plus/icons-vue": "^2.1.0",
    "@sugarat/theme": "^0.1.50",
    "element-plus": "^2.4.1",
    "vue": "^3.3.7"
  },
  "devDependencies": {
    "sass": "^1.69.5",
    "typescript": "^4.9.5",
    "vitepress": "1.0.0-rc.24"
  },
  "author": "Deer404",
  "license": "MIT"
}

报错信息

failed to load config from /Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/docs/.vitepress/config.ts
failed to start server. error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vitepress-plugin-mermaid/dist/vitepress-plugin-mermaid.umd.js from /Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@sugarat/theme/node.js not supported.
vitepress-plugin-mermaid.umd.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename vitepress-plugin-mermaid.umd.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vitepress-plugin-mermaid/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at _require.extensions.<computed> [as .js] (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:66343:17)
    at getMarkdownPlugins (/Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@sugarat/theme/node.js:296:35)
    at getThemeConfig (/Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@sugarat/theme/node.js:583:26)
    at Object.<anonymous> (/Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/docs/.vitepress/config.ts:26:48)
    at _require.extensions.<computed> [as .js] (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:66340:24)
    at loadConfigFromBundledFile (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:66348:21)
    at async loadConfigFromFile (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:66171:28)
    at async resolveUserConfig (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vitepress/dist/node/serve-FiwKdDMo.js:19878:27)
    at async resolveConfig (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vitepress/dist/node/serve-FiwKdDMo.js:19811:48)
    at async createServer (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vitepress/dist/node/serve-FiwKdDMo.js:70084:18)
    at async createDevServer (file:///Volumes/DataDocument/CodeSpace/Deer404/blog_vitepress/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vitepress/dist/node/cli.js:405:20)

当文章长度不足一个屏幕高度时, 评论按钮会显示错误

很喜欢作者的作品, 确实是我用过最喜欢的VitePress主题!

在开启评论之后出现了一个问题: https://miaobuao.github.io/posts/%E5%AE%89%E8%A3%85electron%E5%8D%A1%E4%BD%8F.html

如图, 当文章比较短的时候, 按照逻辑应该是不显示评论按钮, 但是却居中显示了, 应该是BUG
image

当切换到一个较长的文章, 再重新切换回出现问题的短文章时, 评论按钮就被隐藏了.

rss plugin: frontmatter.publish 更多解释?

我想找一个控制文章是否输出到 RSS 的选项,看到 frontmatter.publish 很适合。

Q:是否只影响 rss plugin 生成逻辑,不影响 vitepress 其他部分?比如 sitemap 中还是包含了 publish = false 的文章

提几个优化的建议

首先得夸一下,这个主题是我这几天在github上找到的基于vitepress的体验最好的主题。

基于这个主题,我构建了自己的博客ZQ-XU,非常感谢owner的分享!

在构建个人博客期间,我也有些许的建议,希望owner在后续的开发中可以考虑一下:

  • 多语言的支持,当前貌似是只支持单语种;
  • 首页文章和左侧边栏的目录(相关文章)支持自定义/排序,当前貌似是根据当前路径下的文件根据date属性自动排序的(如果没有指定date属性,那么更改了以前的文章,则会打乱原来的顺序);
  • 背景图片的配置,我是参考vitepress的文档,在styles的css文件中覆盖了background-image属性;
  • 右侧边栏的标题默认是支持到二级标题的,我是参考了vitepress的文档,根据属性'outline'来配置的,这个可以考虑补充到文档中(对于新人会比较友好)。

祝好~

若干个问题

以下方案可能是治标不治本的,我前端太菜了,还请作者有空时看看怎么解决。

环境

  • OS:Windows 11 23H2 22631.3296 X64
  • Node:v20.10.0 X64
  • IDE:VSCode

pnpm install

报错:1

删除 packages/theme/package.json 下的

"pnpm": {
    "peerDependencyRules": {
      "ignoreMissing": [
        "@algolia/client-search",
        "search-insights"
      ]
    }
  }

解决

pnpm dev

如果使用 pnpm --filter 'blogpress' dev

报错:No projects matched the filters...

改为 pnpm -r --filter=./packages/blogpress dev 解决

pnpm buildlib

如果使用 pnpm run '/^build:.*/'

报错:0

改为 pnpm run \"/^build:.*/\"
报错:No projects matched the filters...

改为 pnpm -r --filter=./packages/** build 解决

但是有很多这种警告,虽然不影响启动,但感觉还是要解决的:
4
5
6

启动后

控制台警告:[Vue warn]: Component "Mermaid" has already been registered in target app.

packages/theme/src/index.ts
注册前先判断是否已经注册过

    if (!ctx.app.component('Mermaid')) {
      ctx.app.component('Mermaid', Mermaid as any)
    }

index.md问题

还记得index.md,vitepress不能显示这个markdown,最后你怎么解决了

标题栏如何配置?

我在docs/.vitepress/config.ts的const blogTheme = getThemeConfig({nav:[{text:'home',link:'/'}]....
不起作用呢

mac打包失败

Binary failed to download — package expected to have downloaded the binary to /Users/june/Desktop/my_blog/node_modules/.pnpm/[email protected]/node_modules/pagefind/bin/pagefind_extended during its postinstall
Do you have install scripts disabled for npm?
Try running npm config set ignore-scripts false and re-installing.
Otherwise, your platform might not be supported. Open an issue on GitHub!
build error:

pagefind 不支持mac吗

tabs支持

          > 我这看不到你发的图片,看着你没有上传成功

image
docsify其中的一个组件

<script src="https://cdn.jsdelivr.net/npm/docsify-tabs@1"></script>

Originally posted by @wanghuohuoyan in #94 (comment)

请教下,样式怎么修改

左边和右边的宽度有块区域空着
image
我想改下宽度,还有中间区域,宽度也比较窄,我也想改宽些。
java开发,前端开始学🤣,以前用的docsify

搜索内容是否可以忽略大小写

感觉你的这个插件很好用,但是我在使用的时候遇到这样一个问题,在搜索框里面输入的内容并无法过滤文章中的大小写字母。这样感觉会损失效率,你觉得呢?

文案错误

技术周刊第79期,“现代的 js 中,主要存在 CommonJS(CJS) 与 CommonJS(CJS) 两种模块系统。”,这段文案cjs写重复了😁

请问本项目能运行吗

image
按照提示,pnpm i 之后pnpm dev显示用问题,No projects matched the filters in "E:\GitHub\sugar-blog"

编写的其中一个文档引入css样式,发布时会导致全部md文件都引入这个样式

我在其中一个文档中引入自动加标题的css样式

<style type="text/css">
    h1 { counter-reset: h2counter; }
    h2 { counter-reset: h3counter; }
    h3 { counter-reset: h4counter; }
    h4 { counter-reset: h5counter; }
    h5 { counter-reset: h6counter; }
    h6 { }
    h2:before {
      counter-increment: h2counter;
      content: counter(h2counter) ".\0000a0\0000a0";
    }
    h3:before {
      counter-increment: h3counter;
      content: counter(h2counter) "."
                counter(h3counter) ".\0000a0\0000a0";
    }
    h4:before {
      counter-increment: h4counter;
      content: counter(h2counter) "."
                counter(h3counter) "."
                counter(h4counter) ".\0000a0\0000a0";
    }
    h5:before {
      counter-increment: h5counter;
      content: counter(h2counter) "."
                counter(h3counter) "."
                counter(h4counter) "."
                counter(h5counter) ".\0000a0\0000a0";
    }
    h6:before {
      counter-increment: h6counter;
      content: counter(h2counter) "."
                counter(h3counter) "."
                counter(h4counter) "."
                counter(h5counter) "."
                counter(h6counter) ".\0000a0\0000a0";
    }
</style>

dev的时候显示正常,build后每个md文件都加入了这个样式
特别是首页标题这里都自动加了数字
首页内容如下

layout: home
blog:
    name: windstarry的Blog
    motto: 记录学习,记录生活
    inspiring: 知识是一点一滴积累起来的...
    pageSize: 6

发布后显示
FireShot Capture 003 - windstarry's blog - windstarry's blog - windstarry github io
dev的显示
FireShot Capture 004 - windstarry's blog - windstarry's blog - localhost

_pagefind/pagefind.js 404

@sugarat/theme版本 0.1.30

在html中有这个动态导入代码

import('/_pagefind/pagefind.js')
  .then((module) => {
    window.__pagefind__ = module
  })
  .catch(() => {
    console.log('not load /_pagefind/pagefind.js')
  })

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.