当前位置: 首页 > news >正文

thinkphp做的网站源码怎么做网页啊

thinkphp做的网站源码,怎么做网页啊,绍兴网站建设费用,蓬莱网站设计使用VuePress2.X构建个人知识博客,并且用个人域名部署到GitHub Pages中 什么是VuePress VuePress 是一个以 Markdown 为中心的静态网站生成器。你可以使用 Markdown 来书写内容(如文档、博客等),然后 VuePress 会帮助你生成一个…

使用VuePress2.X构建个人知识博客,并且用个人域名部署到GitHub Pages中

什么是VuePress

VuePress 是一个以 Markdown 为中心的静态网站生成器。你可以使用 Markdown 来书写内容(如文档、博客等),然后 VuePress 会帮助你生成一个静态网站来展示它们。VuePress 诞生的初衷是为了支持 Vue.js 及其子项目的文档需求,但是现在它已经在帮助大量用户构建他们的文档、博客和其他静态网站。官网:

https://vuepress.vuejs.org/zh/

VuePress1.X和VuePress2.X区别

最开始星哥使用的是VuePress1.X(https://vuepress.xgss.net/),后期由于nodejs升级了导致VuePress1.X使用不了,一直报错。

无奈升级到VuePress2.X,2.x和1.x有很多不兼容的地方,也踩了很多坑,记录一下。

image-20250606145334981

安装VuePress

环境: window10

最好有自己的域名,星哥这里使用的事vuepress-v2.xgss.net

软件安装:nodejs和git

由于官方的教程docs.yml文件是pnpm作为包管理器,本人最开始使用的是yarn导致GitHub Actions失败,所以使用pnpm重新安装VuePress

星哥最开始使用的yarn,后来改成了pnpm,所以这个笔记遇到yarn一律改成pnpm既可。

https://vuepress.vuejs.org/zh/guide/deployment.html#github-pages

重新安装VuePress

安装
$ npm install -g pnpm
added 1 package in 3s
$ pnpm -v
10.11.1pnpm create vuepress vuepress-starter
mkdir vuepress-starter
cd vuepress-starter安装vuepress
pnpm init
pnpm add -D vuepress@next vue
pnpm add -D @vuepress/bundler-vite@next @vuepress/theme-default@next安装调试插件
pnpm add -D sass-embedded
安装搜索插件
pnpm add -D @vuepress/plugin-search@next启动开发服务器
pnpm docs:dev构建网站:
pnpm docs:build

以下是使用yarn安装,这里推荐使用pnpm安装

你可以通过 create-vuepress 直接创建项目模板。
yarn create vuepress vuepress-starter创建并进入一个新目录
mkdir vuepress-starter
cd vuepress-starter初始化项目
git init
yarn init# 安装 vuepress
yarn add -D vuepress@next
# 安装打包工具和主题
yarn add -D @vuepress/bundler-vite@next @vuepress/theme-default@next

创建 VuePress 配置文件

docs/.vuepress/config.js

mkdir -p docs/.vuepress/
vi docs/.vuepress/config.js
填入一下配置:
import { viteBundler } from '@vuepress/bundler-vite'
import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'export default defineUserConfig({bundler: viteBundler(),theme: defaultTheme(),
})

创建你的第一篇文档

echo '# Hello VuePress' > docs/README.md

启动开发服务器

你可以在 package.json 中添加一些 scripts :

{"scripts": {"docs:dev": "vuepress dev docs","docs:build": "vuepress build docs"}
}

image-20250605102058056

运行 docs:dev 脚本可以启动开发服务器:

yarn docs:dev

VuePress 会在 http://localhost:8080 启动一个热重载的开发服务器。当你修改你的 Markdown 文件时,浏览器中的内容也会自动更新。

报错:

image-20250605102257832

yarn add -D sass-embedded

再启动开发服务器

$ yarn docs:dev
yarn run v1.22.22
$ vuepress dev docs
√ Initializing and preparing data - done in 58ms
10:22:16 [vite] (client) Re-optimizing dependencies because lockfile has changedvite v6.3.5 dev server running at:➜  Local:   http://localhost:8080/➜  Network: http://192.168.1.251:8080/➜  Network: http://192.168.52.1:8080/➜  Network: http://192.168.152.1:8080/

使用浏览器访问http://localhost:8080/

image-20250605102401921

构建你的网站

运行 docs:build 脚本可以构建你的网站:

yarn docs:build

查看vuepress版本

yarn list vuepress

vuepress主题(报错)

更换主题,一直报错就决定不换主题了,使用默认主题了!

官网: https://marketplace.vuejs.press/zh/themes/

VuePress Theme Mix

https://vuepress-theme-mix.netlify.app/zh/guide/getting-started.html

安装VuePress Theme Mix

yarn add -D vuepress-theme-mix@next

使用与配置

import { defineUserConfig } from 'vuepress'
import mixTheme from 'vuepress-theme-mix'export default defineUserConfig({// ...theme: mixTheme({// 在这里配置主题}),// ...
})

VuePress配置搜索

安装插件

首先,在你的 VuePress 项目中安装该插件:
pnpm add -D @vuepress/plugin-search@next
# 或者
yarn add -D @vuepress/plugin-search@next
# 或者
npm i -D @vuepress/plugin-search@next

配置config.js

.vuepress/config.js 示例:
import { searchPlugin } from '@vuepress/plugin-search'module.exports = {plugins: [searchPlugin({// 插件选项// 可以配置的选项包括:// maxSuggestions: 5, // 最多显示多少条搜索结果// isSearchable: (page) => page.path !== '/', // 排除特定页面// hotKeys: ['s', '/'], // 激活搜索框的快捷键// locales: { // 多语言支持//   '/': {//     placeholder: '搜索',//   },//   '/en/': {//     placeholder: 'Search',//   },// },// get.Display.Text: (page) => { /* 自定义搜索结果显示文本 */ },// search: (query, pages) => { /* 自定义搜索逻辑 */ },}),],
}

报错1

使用

yarn docs:build

报错,由于图片没有上传到oss中导致报错。

error [vite:asset] Could not load G:/STAR学习/vuepress-starter/docs/./chatgpt/H:/typora_images/image-20240415180831846.png (imported by docs/.vuepress/.temp/pages/chatgpt/15.免费使用GPT-4的3种方法,白嫖大模型.html.vue): ENOENT: no such file or directory, open 'G:\STAR学习\vuepress
-starter\docs\chatgpt\H:\typora_images\image-20240415180831846.png'

解决:

grep -R 'typora_images' ./*| grep -v '.vuepress/'
查看所有未上传的图片

把所有的图片上传到oss中,再生成yarn docs:build

配置到GitHub Pages

前置条件,需要你有自己的域名,如果没有自有的域名,也可以使用github的域名,但是国内可能访问不畅。

自己的域名CNAME到 https://<USERNAME>.github.io或者使用官方域名: https://<USERNAME>.github.io/<REPO>/

这里星哥使用vuepress-v2.xgss.net 解析到 funet8.github.io

1.github新建仓库

新建git 仓库
vuepress-v2.xgss.net克隆到本地
git clone git@github.com:funet8/vuepress-v2.xgss.net.git
把docs的文档拷贝进去

2.执行

#提交到github仓库-vuepress-v2分支
#git init
git add -A
git commit -m 'deploy.sh-vuepressV2脚本自动提交'
git push -f git@github.com:funet8/vuepress-v2.xgss.net.git main

有两个分支

image-20250605161934191

3.设置域名访问

自有域名 vuepress-v2.xgss.net 解析到github中

Settings --> Pages

image-20250605162124719

把 vuepress-v2.xgss.net CNAME解析到 funet8.github.io
把 你的域名  解析到 <你的github账号名>.github.io

image-20250605162742075

等待解析生效,github会提示DNS check successful

勾选 Enforce HTTPS,强制

直接根据官方文档先初始化项目就行了,注意文档的版本,v1和v2还是有很多地方不同的。

4.用 GitHub Actions 部署到 GitHub Pages

参考:https://vuepress.vuejs.org/zh/guide/deployment.html#github-pages

创建 .github/workflows/docs.yml 文件来配置工作流。

name: docson:# 每当 push 到 main 分支时触发部署push:branches: [main]# 手动触发部署workflow_dispatch:jobs:docs:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4with:# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录fetch-depth: 0- name: 设置 pnpmuses: pnpm/action-setup@v4- name: 设置 Node.jsuses: actions/setup-node@v4with:# 选择要使用的 node 版本node-version: 22# 缓存 pnpm 依赖cache: pnpm- name: 安装依赖run: pnpm install --frozen-lockfile# 运行构建脚本- name: 构建 VuePress 站点run: pnpm docs:build# 查看 workflow 的文档来获取更多信息# @see https://github.com/crazy-max/ghaction-github-pages- name: 部署到 GitHub Pagesuses: crazy-max/ghaction-github-pages@v4with:# 部署到 gh-pages 分支target_branch: gh-pages# 部署目录为 VuePress 的默认输出目录build_dir: docs/.vuepress/distenv:# @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secretGITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

提交代码,触发Actions

image-20250605165314078

报错没有配置packageManager

Error: No pnpm version is specified. Please specify it by one of the following ways: - in the GitHub Action config with the key "version" - in the package.json with the key "packageManager"

image-20250605165722852

解决

在 package.json添加

"packageManager": "pnpm@10.11.1"或者在 .github/workflows/docs.yml 文档中添加- name: 设置 pnpmuses: pnpm/action-setup@v4with:version: '8.x'

报错无pnpm-lock.yaml

Dependencies lock file is not found in /home/runner/work/vuepress-v2.xgss.net/vuepress-v2.xgss.net. Supported file patterns: pnpm-lock.yaml

image-20250605171442396

解决

安装pnpm

$ npm install -g pnpm
added 1 package in 3s$ pnpm -v
10.11.1$rm -rf node_modules/$ pnpm install

pnpm包管理的问题

由于官方的教程docs.yml文件是pnpm作为包管理器,本人最开始使用的是yarn导致GitHub Actions失败,所以重新安装VuePress

https://vuepress.vuejs.org/zh/guide/deployment.html#github-pages

重新安装VuePress

mv package.json package-yarn.json
rm -rf node_modules安装vuepress
pnpm init
pnpm add -D vuepress@next vue
pnpm add -D @vuepress/bundler-vite@next @vuepress/theme-default@next调试插件
pnpm add -D sass-embedded
搜索插件
pnpm add -D @vuepress/plugin-search@next启动开发服务器
pnpm docs:dev构建网站:
pnpm docs:build

5.工作流权限

在仓库的 Settings > Actions > General,确保 GITHUB_TOKEN 的权限被设置为 write 权限(即推送权限)。

image-20250605183211238

如图,勾选:Read and write permissions

保存。

6.提交成功

image-20250606094256875

但是当我访问页面的时候

https://funet8.github.io/vuepress-v2.xgss.net/

无尽的404让人头疼

image-20250606094350107

再次修改

docs\.vuepress\config.js
里面的配置
base: '/vuepress-v2.xgss.net/', // 部署到github相关的配置 
则是使用https://funet8.github.io/vuepress-v2.xgss.net/ 访问

改成使用域名,发现缺少CNAME 文件

于是在docs.yml文件中添加一步

      - name: Add CNAME file # 添加 CNAME 文件run: echo 'vuepress-v2.xgss.net' > docs/.vuepress/dist/CNAME

最终使用域名 vuepress-v2.xgss.net 可以访问博客页面了。

最后

写文不易,如果你都看到了这里,请点个赞和在看,分享给更多的朋友;也别忘了关注星哥玩云!这里有满满的干货分享,还有轻松有趣的技术交流~点个赞、分享给身边的小伙伴,一起成长,一起玩转技术世界吧! 😊

通过以上步骤,你成功地使用VuePress 2.X搭建了一个个人知识博客,并将其部署到GitHub Pages,同时还配置了自己的个人域名。这不仅为你提供了一个高效的知识管理平台,还能让你更好地记录学习过程并分享给他人。希望这篇教程对你有所帮助,祝你搭建博客愉快!

http://www.dtcms.com/a/524800.html

相关文章:

  • 备份一体机:数据同步困局突围指南:毫秒级实时同步如何根治80%业务痛点
  • nexus上传jar包图文步骤
  • 【2025 最新】ArcGIS for JS TileLayer/FeatureLayer/ImageLayer 用法对比
  • AntV X6实战:实现节点四边自动连接与自定义箭头的完整配置
  • 黄骅市网站建设广州市官方网站
  • 华为OD机考双机位A卷 - 最长的密码 / 寻找密码 (C++ Python JAVA JS GO)
  • ELK日志分析系统完整部署与应用指南
  • 浦江做网站茂名网站建设公司
  • 【CVE-2025-40778】通过未经请求的答复记录进行 BIND 9 缓存中毒(内含复现步骤)
  • 架构权衡与实践:基于“约束大于规范”的缓存组件封装
  • 【实战经验】飞牛云 如何使用 SSD 缓存加速?
  • 数据结构--顺序表与链表
  • 网站排名优化课程深圳网站建设开发哪家好
  • 使用 WebSocket 实现手机控制端与电脑展示端的实时通信,支持断线重连、状态同步和双向数据交互。(最优方案)
  • 快递鸟 MCP Server:AI 工具解锁 物流 API 能力,开启智能物流新生态
  • UV Python 包和项目管理工具
  • 使用 Quill 实现编辑器功能
  • 企业网站建设的可行性图片编辑软件加文字
  • 零基础网站建设视频教程做淘宝美工的网站
  • 微米级光斑分析仪市场报告:政策、趋势与前景深度解析
  • 达梦 DM Database 集群:从概念到开发场景
  • 面向社科研究者:用深度学习做因果推断(一)
  • 站长seo计费系统比较好的网页模板网站
  • 【学习笔记】大模型
  • ES7243E 模拟音频转I2S输入给BES I2S_Master数据运行流程分析
  • 虚拟内存与RAM
  • 广州花都区网站建设长沙seo优化排名推广
  • 广告公司网站模版做一家网站要多少钱
  • 【Linux知识】Linux文本操作相关命令行
  • Port设置功能开发实践: Pyside6 MVC架构与Model/View/Delegate模式的应用