u
This commit is contained in:
1 parent
3ef263f5cc
commit
b19241d695
10 files changed
+543
-124
No files matched your search
@@ -0,0 +1,3 @@
|
||||
PostgreSQL(常简称“Postgres”)是一款强调可扩展性和标准兼容性的对象关系型数据库管理系统(ORDBMS)。作为数据库服务器,其核心功能是安全存储数据并支持最佳实践,同时支持本地或网络(含互联网)中的应用程序按需检索数据。它可处理从小型单机应用到高并发互联网应用的各类负载,最新版本还支持数据库复制以提升安全性和可扩展性。
|
||||
|
||||
PostgreSQL 实现了 SQL:2011 标准的大部分功能,支持 ACID 事务(含多数 DDL 语句),通过多版本并发控制(MVCC)避免锁竞争,提供防脏读和完全可序列化能力。它支持复杂 SQL 查询、多种索引类型、可更新视图、物化视图、触发器、外键,以及函数和存储过程,并拥有丰富的第三方扩展。此外,PostgreSQL 支持从其他数据库迁移,通过标准 SQL 兼容和迁移工具,甚至可通过内置或第三方扩展模拟专有数据库的特性(如 Oracle)。
|
||||
@@ -0,0 +1,15 @@
|
||||
## Docker安装
|
||||
dockerhub网站:https://hub.docker.com/_/postgres
|
||||
|
||||
1. 拉取
|
||||
|
||||
```bash
|
||||
docker pull postgres@18
|
||||
```
|
||||
2. 运行
|
||||
|
||||
```bash
|
||||
docker run --name postgres18 -e POSTGRES_PASSWORD=xxx -p 5432:5432 -d postgres:18
|
||||
```
|
||||
|
||||
> 初始化数据库:postgres 默认用户名:postgres
|
||||
@@ -0,0 +1,15 @@
|
||||
Docker 是一个 容器化平台,可以让你把应用程序和它运行所需的环境打包在一起,形成一个独立的“容器”。
|
||||
简单来说,它就像一个轻量级的虚拟机,但比虚拟机更快、更省资源。
|
||||
|
||||
## 概念
|
||||
1. 镜像(Image)
|
||||
- 镜像是一个 只读模板,包含应用程序和依赖环境。
|
||||
- 可以理解为应用的快照,像“配方”。
|
||||
2. 容器(Container)
|
||||
- 容器是镜像的 运行实例,可以启动、停止、删除。
|
||||
- 可以理解为根据配方做出来的“饭菜”。
|
||||
3. Dockerfile
|
||||
- 用来定义镜像内容的文件,相当于“配方清单”。
|
||||
- 里面写明了基础镜像、依赖、环境变量、运行命令等。
|
||||
4. Docker Hub
|
||||
- 官方提供的镜像仓库,可以下载别人已经打包好的镜像,也可以上传自己的镜像。
|
||||
@@ -0,0 +1,291 @@
|
||||
## 快速安装
|
||||
|
||||
轩辕提供的安装脚本:
|
||||
|
||||
```bash
|
||||
bash <(wget -qO- https://xuanyuan.cloud/docker.sh)
|
||||
```
|
||||
|
||||
> 参考网站:https://zhuanlan.zhihu.com/p/24461370776
|
||||
|
||||
## 脚本安装
|
||||
|
||||
### 对于基于Debian的系统(如Ubuntu、Debian)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ 卸载旧版本 Docker
|
||||
# -------------------------
|
||||
sudo apt-get remove -y \
|
||||
docker \
|
||||
docker-engine \
|
||||
docker.io \
|
||||
containerd \
|
||||
runc \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io \
|
||||
docker-compose-plugin
|
||||
|
||||
# 可选:清理残留数据(慎用,会删除容器和镜像)
|
||||
# sudo rm -rf /var/lib/docker /var/lib/containerd
|
||||
|
||||
echo "旧版本 Docker 已卸载(如果存在)"
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ 更新软件包列表并安装必要依赖
|
||||
# -------------------------
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ca-certificates curl software-properties-common lsb-release
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ 创建密钥存储目录
|
||||
# -------------------------
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ 下载Docker官方GPG密钥
|
||||
# -------------------------
|
||||
sudo curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg -o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
|
||||
# -------------------------
|
||||
# 5️⃣ 添加 Docker 仓库
|
||||
# -------------------------
|
||||
if [ "$(lsb_release -is)" = "Ubuntu" ]; then
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
elif [ "$(lsb_release -is)" = "Debian" ]; then
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
fi
|
||||
|
||||
sudo apt-get update
|
||||
echo "Docker 仓库已添加。"
|
||||
|
||||
# -------------------------
|
||||
# 6️⃣ 安装 Docker 及相关组件
|
||||
# -------------------------
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
|
||||
echo "Docker 安装完成 ✅"
|
||||
```
|
||||
|
||||
### 对于基于RHEL的系统(如CentOS、RHEL)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ 卸载旧版本 Docker
|
||||
# -------------------------
|
||||
sudo yum remove -y docker \
|
||||
docker-client \
|
||||
docker-client-latest \
|
||||
docker-common \
|
||||
docker-latest \
|
||||
docker-latest-logrotate \
|
||||
docker-logrotate \
|
||||
docker-engine \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io \
|
||||
docker-compose-plugin
|
||||
|
||||
echo "旧版本 Docker 已卸载(如果存在)"
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ 安装 yum 配置管理工具
|
||||
# -------------------------
|
||||
sudo yum install -y yum-utils
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ 检测系统发行版并添加 Docker 仓库
|
||||
# -------------------------
|
||||
if [ -f /etc/centos-release ]; then
|
||||
# CentOS 系统
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
# RHEL 系统
|
||||
# 注意:RHEL 用户需要启用订阅管理仓库
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
|
||||
else
|
||||
echo "未识别的发行版,脚本退出。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ 更新 yum 缓存
|
||||
# -------------------------
|
||||
sudo yum makecache fast
|
||||
echo "Docker 仓库已添加。"
|
||||
|
||||
# -------------------------
|
||||
# 5️⃣ 安装 Docker 及相关组件
|
||||
# -------------------------
|
||||
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
|
||||
echo "Docker 安装完成 ✅"
|
||||
```
|
||||
|
||||
### 通用脚本
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# -------------------------
|
||||
# 1️⃣ 卸载旧版本 Docker
|
||||
# -------------------------
|
||||
remove_old_docker() {
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
sudo apt-get remove -y docker docker-engine docker.io containerd runc docker-ce docker-ce-cli containerd.io docker-compose-plugin || true
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
sudo yum remove -y docker \
|
||||
docker-client \
|
||||
docker-client-latest \
|
||||
docker-common \
|
||||
docker-latest \
|
||||
docker-latest-logrotate \
|
||||
docker-logrotate \
|
||||
docker-engine \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io \
|
||||
docker-compose-plugin || true
|
||||
fi
|
||||
echo "旧版本 Docker 已卸载(如果存在)"
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# 2️⃣ 安装 Docker(DEB 系统)
|
||||
# -------------------------
|
||||
install_docker_deb() {
|
||||
local distro=$1
|
||||
local codename=$2
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common lsb-release
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
sudo curl -fsSL "https://download.docker.com/linux/$distro/gpg" -o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/$distro $codename stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
sudo systemctl enable --now docker
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# 3️⃣ 安装 Docker(RPM 系统)
|
||||
# -------------------------
|
||||
install_docker_rpm() {
|
||||
local distro=$1
|
||||
if [ "$distro" = "fedora" ]; then
|
||||
sudo dnf -y install dnf-plugins-core
|
||||
else
|
||||
sudo yum install -y yum-utils
|
||||
fi
|
||||
sudo yum-config-manager --add-repo "https://download.docker.com/linux/$distro/docker-ce.repo"
|
||||
sudo yum makecache fast
|
||||
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo systemctl enable --now docker
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# 4️⃣ 主流程
|
||||
# -------------------------
|
||||
remove_old_docker
|
||||
|
||||
# 检测 Linux 发行版
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
else
|
||||
echo "无法确定您的 Linux 发行版。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $ID in
|
||||
ubuntu|debian|raspbian)
|
||||
echo "检测到 $ID $VERSION_CODENAME,开始安装 Docker..."
|
||||
install_docker_deb $ID $VERSION_CODENAME
|
||||
;;
|
||||
centos|rhel|fedora|sles)
|
||||
echo "检测到 $ID,开始安装 Docker..."
|
||||
install_docker_rpm $ID
|
||||
;;
|
||||
*)
|
||||
echo "不支持的 Linux 发行版:$ID"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Docker 及 Docker Compose 安装完成 ✅"
|
||||
```
|
||||
|
||||
### 运行脚本
|
||||
|
||||
```bash
|
||||
# 1.创建脚本
|
||||
vim docker-script.sh
|
||||
|
||||
# 2.输入内容 i 进行编辑模式, :wq 保存
|
||||
|
||||
# 3.赋予权限
|
||||
chmod +x docker-script.sh
|
||||
|
||||
# 4.运行脚本
|
||||
./docker-script.sh
|
||||
```
|
||||
|
||||
## 镜像设置
|
||||
|
||||
不设置镜像会导致拉取速度非常慢
|
||||
访问 https://api.suoyinmulu.com/open/v1/docker-hub/seeded-up/lists 获取最新的docker镜像,将 list 中的内容拷贝到 docker 中的 registry-mirrors 中。
|
||||
|
||||
```bash
|
||||
sudo vim /etc/docker/daemon.json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"registry-mirrors": [
|
||||
// list
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
刷新:
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload && sudo systemctl restart docker
|
||||
```
|
||||
|
||||
## 问题
|
||||
### 权限不足
|
||||
1. 添加docker用户组(默认有)
|
||||
|
||||
```
|
||||
sudo groupadd docker
|
||||
```
|
||||
|
||||
2. 添加当前用户到docker组中
|
||||
|
||||
```
|
||||
sudo gpasswd -a $USER docker
|
||||
```
|
||||
|
||||
3. 更新用户组
|
||||
|
||||
```
|
||||
newgrp docker
|
||||
```
|
||||
|
||||
4. 重启生效 或 提前执行(建议重启)
|
||||
|
||||
```
|
||||
sudo chown root:docker /var/run/docker.sock
|
||||
```
|
||||
File renamed without changes.
@@ -1,123 +0,0 @@
|
||||
关于文档的创建和配置
|
||||
|
||||
## 1. navbar 配置
|
||||
|
||||
在 `docusaurus.config.ts` 文件中进行配置, `config` - `themeConfig` - `navbar` - `items`
|
||||
|
||||
### 1.1 单级导航
|
||||
|
||||
在 `docs` 文件夹下创建 `test.md` 文件,并在 `items` 配置项中添加:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"to": "/docs/test",
|
||||
"label": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
刷新页面,即可进行预览
|
||||
|
||||
### 1.2 多级导航
|
||||
|
||||
docusaurus 的 navbar 最多支持两级导航,比如:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "编程语言",
|
||||
"position": "left",
|
||||
"items": [
|
||||
{
|
||||
"label": "Stack Overflow",
|
||||
"href": "https://stackoverflow.com/questions/tagged/docusaurus"
|
||||
},
|
||||
{
|
||||
"label": "Discord",
|
||||
"href": "https://discordapp.com/invite/docusaurus"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 2. 侧边栏配置
|
||||
|
||||
docs 的侧边栏配置主要在 `sidebars.ts` 文件中
|
||||
|
||||
### 2.1 自动生成
|
||||
|
||||
在 docs 目录中创建 `coding/java` 目录,在 `sidebar.ts` 文件中添加配置:
|
||||
|
||||
```ts
|
||||
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
|
||||
|
||||
const sidebars: SidebarsConfig = {
|
||||
// coding 目录下的自动生成的 Java 相关文档
|
||||
javaSidebar: [{ type: 'autogenerated', dirName: 'coding/java' }]
|
||||
}
|
||||
|
||||
export default sidebars
|
||||
```
|
||||
|
||||
修改 `docusaurus.config.ts` 文件:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "编程语言",
|
||||
"position": "left",
|
||||
"items": [
|
||||
{
|
||||
"type": "docSidebar",
|
||||
"label": "Java",
|
||||
"sidebarId": "javaSidebar"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
提示:
|
||||
|
||||
- `sidebarId` 需要和 `SidebarsConfig` 中的 key 保持一致
|
||||
- `type: 'autogenerated'` 表示自动生成
|
||||
- **自动生成模式下 将自动根据目录和目录下的文件自动构建侧边栏**
|
||||
|
||||
### 2.2 手动配置
|
||||
|
||||
```ts
|
||||
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
|
||||
|
||||
const sidebars: SidebarsConfig = {
|
||||
// 手动配置的侧边栏
|
||||
javaSidebar: [
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Java 基础',
|
||||
items: ['coding/java/intro', 'coding/java/advanced'],
|
||||
},
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Java 框架',
|
||||
items: ['coding/java/spring-boot', 'coding/java/hibernate'],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export default sidebars
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
关于文档的创建和配置
|
||||
|
||||
## navbar 配置
|
||||
|
||||
在 `docusaurus.config.ts` 文件中进行配置, `config` - `themeConfig` - `navbar` - `items`
|
||||
|
||||
### 单级导航
|
||||
|
||||
在 `docs` 文件夹下创建 `test.md` 文件,并在 `items` 配置项中添加:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"to": "/docs/test",
|
||||
"label": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
刷新页面,即可进行预览
|
||||
|
||||
### 多级导航
|
||||
|
||||
docusaurus 的 navbar 最多支持两级导航,比如:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "编程语言",
|
||||
"position": "left",
|
||||
"items": [
|
||||
{
|
||||
"label": "Stack Overflow",
|
||||
"href": "https://stackoverflow.com/questions/tagged/docusaurus"
|
||||
},
|
||||
{
|
||||
"label": "Discord",
|
||||
"href": "https://discordapp.com/invite/docusaurus"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 图标配置
|
||||
|
||||
以 Github 图标为例
|
||||
修改 `docusaurus.config.ts` 文件:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"aria-label": "GitHub Repository",
|
||||
"className": "navbar--github-link",
|
||||
"href": "https://github.com/oneao",
|
||||
"position": "right",
|
||||
"title": "Github"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
在 `src/css/custom.css` 中添加以下内容:
|
||||
|
||||
```css
|
||||
.navbar--github-link {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
padding: 0.25rem;
|
||||
margin: 0rem 0.2rem;
|
||||
border-radius: 50%;
|
||||
transition: background var(--ifm-transition-fast);
|
||||
}
|
||||
|
||||
.navbar--github-link:hover {
|
||||
background: var(--ifm-color-emphasis-200);
|
||||
}
|
||||
|
||||
.navbar--github-link:before {
|
||||
content: '';
|
||||
height: 100%;
|
||||
display: block;
|
||||
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
|
||||
no-repeat;
|
||||
}
|
||||
|
||||
html[data-theme='dark'] .navbar--github-link:before {
|
||||
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='white' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
|
||||
no-repeat;
|
||||
}
|
||||
|
||||
/* 兼容屏幕过小情况,转为文字 */
|
||||
@media screen and (max-width: 996px) {
|
||||
.navbar--github-link {
|
||||
margin: 0rem;
|
||||
padding: var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal);
|
||||
line-height: 1.25;
|
||||
width: 100%;
|
||||
color: var(--ifm-menu-color);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.navbar--github-link::before {
|
||||
content: 'GitHub';
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
[data-theme='dark'] .navbar--github-link::before {
|
||||
content: 'GitHub';
|
||||
background-image: none;
|
||||
}
|
||||
}
|
||||
```
|
||||
提供两个工具网站仅供参考:
|
||||
- svg 图标库:https://www.svgrepo.com/
|
||||
- svg 转 url 编码:https://yoksel.github.io/url-encoder/zh-cn/
|
||||
|
||||
## 侧边栏配置
|
||||
|
||||
docs 的侧边栏配置主要在 `sidebars.ts` 文件中
|
||||
|
||||
### 自动生成
|
||||
|
||||
在 docs 目录中创建 `coding/java` 目录,在 `sidebar.ts` 文件中添加配置:
|
||||
|
||||
```ts
|
||||
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
|
||||
|
||||
const sidebars: SidebarsConfig = {
|
||||
// coding 目录下的自动生成的 Java 相关文档
|
||||
javaSidebar: [{ type: 'autogenerated', dirName: 'coding/java' }]
|
||||
}
|
||||
|
||||
export default sidebars
|
||||
```
|
||||
|
||||
修改 `docusaurus.config.ts` 文件:
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"items": [
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "编程语言",
|
||||
"position": "left",
|
||||
"items": [
|
||||
{
|
||||
"type": "docSidebar",
|
||||
"label": "Java",
|
||||
"sidebarId": "javaSidebar"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
提示:
|
||||
|
||||
- `sidebarId` 需要和 `SidebarsConfig` 中的 key 保持一致
|
||||
- `type: 'autogenerated'` 表示自动生成
|
||||
- **自动生成模式下 将自动根据目录和目录下的文件自动构建侧边栏**
|
||||
|
||||
### 手动配置
|
||||
|
||||
```ts
|
||||
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
|
||||
|
||||
const sidebars: SidebarsConfig = {
|
||||
// 手动配置的侧边栏
|
||||
javaSidebar: [
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Java 基础',
|
||||
items: ['coding/java/intro', 'coding/java/advanced'],
|
||||
},
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Java 框架',
|
||||
items: ['coding/java/spring-boot', 'coding/java/hibernate'],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export default sidebars
|
||||
```
|
||||
@@ -113,6 +113,23 @@ const config: Config = {
|
||||
label: 'Git',
|
||||
sidebarId: 'GitSidebar',
|
||||
},
|
||||
{
|
||||
type: 'docSidebar',
|
||||
label: 'Docker',
|
||||
sidebarId: 'DockerSidebar',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'dropdown',
|
||||
label: '数据库',
|
||||
position: 'left',
|
||||
items: [
|
||||
{
|
||||
type: 'docSidebar',
|
||||
label: 'PostgreSQL',
|
||||
sidebarId: 'PostgreSQLSidebar',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -8,6 +8,11 @@ const sidebars: SidebarsConfig = {
|
||||
// dev-tools
|
||||
DocusaurusSidebar: [{ type: "autogenerated", dirName: "dev-tools/docusaurus" }],
|
||||
GitSidebar: [{ type: "autogenerated", dirName: "dev-tools/git" }],
|
||||
DockerSidebar: [{ type: "autogenerated", dirName: "dev-tools/docker" }],
|
||||
|
||||
// database
|
||||
PostgreSQLSidebar: [{ type: "autogenerated", dirName: "database/postgresql" }],
|
||||
|
||||
};
|
||||
|
||||
export default sidebars;
|
||||
@@ -113,7 +113,7 @@ html[data-theme="dark"] .navbar--email-link:before {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .navbar--github-link::before {
|
||||
[data-theme="dark"] .navbar--gitee-link::before {
|
||||
content: "Gitee";
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user