搭建自己的wiki知识库【转】

有前端基础,会Markdown、会HTML和CSS,选择 Hexo
有Vue基础可以选择 vuePress 或者 vitePress
会react可以选择 docusaurus
会Go可以选择 Hugo
会Rust可以选择 Zola
会Ruby可以选择 Jekyll
会PHP可以考虑使用 WordPress
其他开源项目:docsify、GitBook


mdBook 是一个命令行工具,可以将 Markdown 文档,变成 HTML 网站。 这样的工具,用在产品信息或是 API 文档, 教程, 课件资料等等场景。

详见:如何使用hugo构建自己的博客 - 知乎

https://segmentfault.com/q/1010000042459229

docsify简单使用

1、下载docsify并解压

# 下载
wget https://codeload.github.com/docsifyjs/docsify/zip/refs/heads/master -o docsify-master.zip

# 下载unzip
yum -y install unzip

# 解压
unzip docsify-master.zip

2、nginx部署

2.1、nginx安装(略)

2.2、使用mv命令移动docsify-master文件到nginx的html目录

2.3、nginx.conf配置

location / {
    root   'docsify所在的目录';
    index  index.html index.htm;

    #add_header Cache-Control "no-cache, no-store, must-revalidate";
    #add_header Pragma "no-cache";
    #add_header Expires 0;
}

2.4、重启nginx

nginx -s reload

2.5、通过浏览器访问项目

3、修改docsify文件

3.1、修改index.html

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <meta charset="UTF-8"/>
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/dark.css">
</head>
<body>
<div id="app">Loading...</div>
<script>
    window.$docsify = {
        name: 'snail',
        loadSidebar: 'zh-cn/_sidebar.md',
        //loadSidebar: true,
        //loadNavbar: true,
        search: {
            placeholder: '搜索',
            noData: '找不到结果',
            depth: 2, // 搜索标题的最大层级, 1 - 6
            namespace: 'docsify',
            pathNamespaces: ['/zh-cn'],
        }
    };
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
</body>
</html>

3.2、根据情况修改_sidebar.md、_navbar.md

3.3、更换css、js使用国内cdn资源

<!-- 更换css、js使用国内cdn资源 -->
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <meta charset="UTF-8"/>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/themes/dark.min.css">
    <title>snail</title>
</head>
<body>
<div id="app">Loading...</div>
<script>
    window.$docsify = {
        name: 'snail',
        //basePath: 'zh-cn/',
        loadSidebar: 'zh-cn/_sidebar.md',
        //loadSidebar: '_sidebar.md',
        //loadSidebar: true,
        //loadNavbar: true,
        search: {
            placeholder: '搜索',
            noData: '找不到结果',
            depth: 2, // 搜索标题的最大层级, 1 - 6
            namespace: 'docsify',
            pathNamespaces: ['/zh-cn'],
        }
    };
</script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/docsify.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/plugins/search.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/plugins/emoji.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/plugins/zoom-image.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify-copy-code/2.1.1/docsify-copy-code.min.js"></script>
</body>
</html>

详见:docsify

Hugo简单使用

1、安装go

# 1、访问go下载页面:https://go.dev/dl/

# 2、下载go
wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz

# 3、解压
tar -xf go1.21.6.linux-amd64.tar.gz

# 4、移动go到/usr/local/go
mv go /usr/local/go

# 5、添加到环境变量
vi /root/.bash_profile 

# 6、/root/.bash_profile文件内容:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

GO_PATH=/usr/local/go/bin

PATH=$PATH:$HOME/bin:$GO_PATH

export PATH


# 7、使环境变量生效
source /root/.bash_profile

# 8、在任意目录执行
go version

2、安装Hugo

# 1、下载
wget https://github.com/gohugoio/hugo/archive/refs/tags/v0.121.2.tar.gz

# 2、解压
tar -xf v0.121.2.tar.gz

# 3、将hugo文件移动到/usr/local/bin/
mv hugo /usr/local/bin/

# 4、生成站点
hugo new site test

# 5、创建一个 about 页面
hugo new about.md

# 6、编辑about.md,删除“draft = true”这行

# 7、安装皮肤
yum -y install git
cd themes
git clone https://github.com/spf13/hyde.git

# 8、运行hugo,浏览器里打开:http://localhost:1313
hugo server --theme=hyde

# 9、部署,执行 Hugo 命令生成最终页面
# 同时会创建public目录,该目录为生成的页面
# 我们可以将public目录的内容部署到nginx中
hugo --theme=hyde

详见:

Quick start | Hugo

Hugo中文文档

mdBook简单使用

1、安装Rust

1.1、配置镜像

下载依赖太慢了? - Rust语言圣经(Rust Course)

# 创建/root/.cargo/config.toml文件
# 选择的镜像源
# 喜欢哪个用哪个吧,没有注释掉的那个就是你选择的
#replace-with = 'ustc'
replace-with = 'tuna'
#replace-with = 'sjtu'
#replace-with = 'rustcc'
#replace-with = 'aliyun'

# 源码地址
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"


# 镜像地址

# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

# 中国科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"

# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"

# 阿里云
[source.aliyun]
registry = "https://code.aliyun.com/rustcc/crates.io-index"

1.2、安装

# rust下载页:https://www.rust-lang.org/tools/install
# 下载
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

 执行命令的结果如下:

中途需要选择

  • 1) Proceed with installation (default) =》默认安装
  • 2) Customize installation                   =》自定义安装
  • 3) Cancel installation                         =》取消安装
info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /root/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /root/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /root/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /root/.profile
  /root/.bash_profile
  /root/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2023-12-28, rust version 1.75.0 (82e1608df 2023-12-21)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 14.3 MiB /  14.3 MiB (100 %)   9.1 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 23.6 MiB /  23.6 MiB (100 %)   9.1 MiB/s in  2s ETA:  0s
info: downloading component 'rustc'
 61.4 MiB /  61.4 MiB (100 %)   9.0 MiB/s in  7s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 14.3 MiB /  14.3 MiB (100 %) 491.2 KiB/s in 31s ETA:  0s    
info: installing component 'rust-std'
 23.6 MiB /  23.6 MiB (100 %)   3.7 MiB/s in 20s ETA:  0s
  4 IO-ops /   4 IO-ops (100 %)   1 IOPS in  3s ETA:  0s    
info: installing component 'rustc'
 61.4 MiB /  61.4 MiB (100 %)   8.0 MiB/s in 24s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - (timeout reading rustc version)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"

最后执行命令:source "$HOME/.cargo/env" 

1.3、命令

cargo build:构建项目
cargo run:运行项目
cargo test:测试项目
cargo doc:为项目构建文档
cargo publish:发布库
cargo --version:查看版本

Getting started - Rust Programming Language

2、安装mdBook

# mdBook下载页:https://github.com/rust-lang/mdBook/releases
# 下载
wget https://github.com/rust-lang/mdBook/archive/refs/tags/v0.4.36.tar.gz

# 解压
tar -xf mdBook-0.4.36.tar.gz

# 重命名
mv mdBook-0.4.36 mdBook

# 进入mdBook目录
cd mdBook

# 运行项目
# cargo run,生成mdbook文件在当前目录下的target/debug/mdbook

# 构建项目
# cargo build --release,生成mdbook文件在当前目录下的target/release/mdbook
cargo build --release

# 复制mdbook到/usr/local/bin/目录下
cp target/release/mdbook /usr/local/bin/

3、mdbook命令

# mdbook命令

Creates a book from markdown files

Usage: mdbook [COMMAND]

Commands:
  init         Creates the boilerplate structure and files for a new book
  build        Builds a book from its markdown files
  test         Tests that a book's Rust code samples compile
  clean        Deletes a built book
  completions  Generate shell completions for your shell to stdout
  watch        Watches a book's files and rebuilds it on changes
  serve        Serves a book at http://localhost:3000, and rebuilds it on changes
  help         Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version
# 初始化项目
mdbook init mybook

# 启动服务
mdbook serve

# 显示结果
2024-01-15 22:25:59 [INFO] (mdbook::book): Book building has started
2024-01-15 22:25:59 [INFO] (mdbook::book): Running the html backend
2024-01-15 22:25:59 [INFO] (mdbook::cmd::serve): Serving on: http://localhost:3000
2024-01-15 22:25:59 [INFO] (mdbook::cmd::watch): Listening for changes...
2024-01-15 22:25:59 [INFO] (warp::server): Server::run; addr=[::1]:3000
2024-01-15 22:25:59 [INFO] (warp::server): listening on http://[::1]:3000

# 使用curl命令访问
curl localhost:3000

详见:

Introduction - mdBook Documentation

介绍 - mdBook 中文指南/文档

介绍 - mdBook 中文文档

### 如何搭建知识库 #### 方法概述 搭建知识库的核心在于系统化地收集、整理和共享信息。这需要明确目标受众的需求以及知识的结构化方式[^1]。通常情况下,知识库的设计应围绕以下几个方面展开:内容分类、检索优化、权限管理和更新机制。 #### 工具推荐 市场上有许多优秀的工具可以帮助快速搭建知识库。以下是几类常见的工具及其适用场景: - **Notion** Notion 是一款集文档编辑、项目管理和数据库于一体的多功能平台,适合个人或小型团队使用。它提供了灵活的内容模块化设计能力,便于创建层次分明的知识体系[^2]。 - **Confluence** Confluence 更倾向于企业级应用,支持复杂的协作环境并具备强大的插件扩展功能。对于需要频繁沟通和技术文档维护的企业来说是一个不错的选择[^3]。 - **TiddlyWiki** TiddlyWiki 提供了一种独特的小块(tiddlers)形式来组织数据,非常适合那些希望采用非线性思维方式进行创作的人群。 - **DokuWiki / MediaWiki** 如果偏好开源解决方案,则 DokuWiki 或者 MediaWiki 可能会更受欢迎。它们允许高度自定义配置,并且社区活跃度高,遇到问题容易找到解决办法。 #### 技术实现要点 当考虑技术层面时,需注意以下几点以确保最终产品既实用又稳定: - 数据存储方案:选择合适的后端服务或者云提供商保障大规模文件上传下载流畅运行。 - 用户界面友好程度:简洁直观的操作流程有助于降低新成员上手难度。 - 安全防护措施:合理设置访问级别防止敏感信息安全泄露风险发生。 - API接口开放情况:方便未来与其他业务系统集成联动发展可能性。 ```python import os def create_directory(path): """ 创建目录 """ try: if not os.path.exists(path): os.makedirs(path) print(f"Directory created at {path}") else: print(f"{path} already exists.") except Exception as e: print(e) create_directory('./knowledge_base') ``` 上述脚本展示了一个简单的 Python 函数用于初始化本地磁盘上的基础路径作为初步物理载体实例演示。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值