diff --git a/_coverage.md b/_coverage.md deleted file mode 100644 index 2805ae33..00000000 --- a/_coverage.md +++ /dev/null @@ -1,7 +0,0 @@ - - -# Docsify使用指南 - -> 💪通灵诗人的个人知识库,欢迎关注。 - -[开始使用 Let Go](/README.md) \ No newline at end of file diff --git a/_coverpage.md b/_coverpage.md new file mode 100644 index 00000000..a5470bd9 --- /dev/null +++ b/_coverpage.md @@ -0,0 +1,16 @@ + + +![](./blog/image/cat.svg) + +# 乘上梦想的帆,轻轻远航 + +> 💪通灵诗人的个人知识库,欢迎关注。 + +[GitHub](https://github.com/Estom) +[Let Go](/README.md) + + + + +![](./blog/image/cover2.jpg) + diff --git a/_footer.md b/_footer.md new file mode 100644 index 00000000..ba2c9e36 --- /dev/null +++ b/_footer.md @@ -0,0 +1 @@ +-------------这是页脚------------------- \ No newline at end of file diff --git a/_navbar.md b/_navbar.md index 40467905..0cca24b2 100644 --- a/_navbar.md +++ b/_navbar.md @@ -1,5 +1 @@ - -* 关注我 - * [Github地址](https://github.com/Estom) - * [Gitee地址](https://gitee.com/Eyestorm) diff --git a/_sidebar.md b/_sidebar.md index 4534530e..4e171567 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -1,7 +1,5 @@ -* Typora+Docsify使用指南 - * [Docsify使用指南](/ProjectDocs/Docsify使用指南.md) - * [Typora+Docsify快速入门](/ProjectDocs/Typora+Docsify快速入门.md) -* Docsify部署 - * [Docsify部署教程](/ProjectDocs/Docsify部署教程.md) \ No newline at end of file +* 设计模式 + * [设计模式之美](./设计模式/0%20设计模式之美.md) + * [设计模式原则](./设计模式/1.1%20单一职责原则.md) \ No newline at end of file diff --git a/blog/generate/README.md b/blog/generate/README.md new file mode 100644 index 00000000..9fedd434 --- /dev/null +++ b/blog/generate/README.md @@ -0,0 +1,191 @@ +# docsify 侧边栏自动生成脚本 + +# docsify sidebar automatically generates scripts + +> 打包成exe文件,程序大小约为5M,还是比较轻量的,主要文件有: +> 1. buildSidebar.exe -> 执行程序后在config.ini设置的根目录下文件夹生成READMD.md和_sidebar.md(名称可自定义) +> 2. config.ini -> 配置生成文件的一些输出文件\忽略情况等选项,具体可以看config.ini文件中注释 + +docsify好像没法自动读取文件夹目录结构并且展示在页面上,需要对每个文件夹配置_sidebar.md文件 + +所以我尝试用python做了一个脚本,基本就用到了os库中的一些函数,所以打包成exe文件大小在可以接受的范围里面,只有5M左右 + +该程序运行的配置参数依赖于config.ini,所以使用前请将config.ini和builSidebar.exe放在同一个目录下 + +在生成md文件结构时,有时想要**忽略一些文件**或者**"_"开头的文件夹**,可以通过config.ini配置 + +```ini +[config] +# docsify根目录 +base_dir=D:\MyData\Data\Docsify\docs +# 忽略以“_”,"."开头的文件,如果要添加新文件,用“|”分隔 +ignore_start_with=_|. +# 只读取".md"格式问价,如果添加新格式,用“|”分隔 +show_file=.md +# 要忽略的文件名,要添加新文件,用“|”分隔 +ignore_file_name=README + + +[outFile] +# 想要在几级目录生成文件,默认"-1"表示所有文件夹生成,"0"表示在根目录生成,可以配合侧边栏折叠插件使用 +create_depth=0 +# 每个文件夹下主页文件名称和侧边栏文件名,默认README.md和_sidebar.md文件,想生成其他名称可修改文字,或者添加用“|”分隔 +eachFile=README.md|_sidebar.md +``` + +# 举例1 + +> 在每一个子文件夹下生成文件 + +原先文件夹的结构是 + +``` +docs +│ .nojekyll +│ ceede.md +│ index.html +│ _coverpage.md +│ +├─PLC +│ │ 电梯群控算法.md +│ │ +│ └─最新测试 +│ hi回答.md +│ +├─_media +│ Pasted image 20230403194327.png +│ +└─启发式算法 + │ 差分进化算法.md + │ + └─测试 + 测试.md +``` + +我在config.ini设置忽略: +1. 以"_","."开头的文件 +2. 忽略文件名为README的文件 +3. 结构中只包括".md"开头的文件 + +运行程序得到的结构是 + +``` +docs +│ .nojekyll +│ ceede.md +│ index.html +│ README.md +│ _coverpage.md +│ _sidebar.md +│ +├─PLC +│ │ README.md +│ │ _sidebar.md +│ │ 电梯群控算法.md +│ │ +│ └─最新测试 +│ hi回答.md +│ README.md +│ _sidebar.md +│ +├─_media +│ Pasted image 20230403194327.png +│ +└─启发式算法 + │ README.md + │ _sidebar.md + │ 差分进化算法.md + │ + └─测试 + README.md + _sidebar.md + 测试.md +``` + +可以看到_media没有被操作,也符合要求 + +## 图片 + +在根目录情况: + +![img0.png](image/img0.png) + +点击PLC之后 + +![img4.png](image/img4.png) + +这种方式生成的结构,点击新文件夹会刷新界面,也可以接受 + +# 举例2 + +> 上面的格式中,点击相应文件夹实际上会跳转,如果不想跳转,可以设置config.ini文件的create_depth参数 +> +> 当参数为-1时候,则每个文件夹生成文件 +> +> 当参数为0时,仅在根目录生成 + +该功能配合侧边栏折叠效果更好 + +原先结构 + +``` +docs +│ .nojekyll +│ ceede.md +│ index.html +│ _coverpage.md +│ +├─PLC +│ │ 电梯群控算法.md +│ │ +│ └─最新测试 +│ hi回答.md +│ +├─_media +│ Pasted image 20230403194327.png +│ +└─启发式算法 + │ 差分进化算法.md + │ + └─测试 + 测试.md +``` + +config.ini中`create_depth`设为0 + +生成的新结构 + +``` +docs +│ .nojekyll +│ ceede.md +│ index.html +│ README.md +│ _coverpage.md +│ _sidebar.md +│ +├─PLC +│ │ 电梯群控算法.md +│ │ +│ └─最新测试 +│ hi回答.md +│ +├─_media +│ Pasted image 20230403194327.png +│ +└─启发式算法 + │ 差分进化算法.md + │ + └─测试 + 测试.md +``` + +可以看到仅在根目录生成了文件 + +## 图片 + +![img.png](image/img.png) + +配合侧边栏折叠插件:https://github.com/iPeng6/docsify-sidebar-collapse + +![img2.png](image/img2.png) \ No newline at end of file diff --git a/blog/generate/buildSidebar.py b/blog/generate/buildSidebar.py new file mode 100644 index 00000000..74a12394 --- /dev/null +++ b/blog/generate/buildSidebar.py @@ -0,0 +1,123 @@ +from configparser import ConfigParser +from os.path import splitext, basename, join, isdir, relpath, abspath +from os import listdir + + +base_dir = None +start_with = None +show_file = None +ignore_file_name = None + +out_file_list = [] +create_depth = -1 + + +def read_config(): + global base_dir, show_file, start_with, ignore_file_name, ReadmeFile, _sidebarFile, out_file_list, create_depth + + cf = ConfigParser() + cf.read("config.ini", encoding='utf-8') + base_dir = cf.get("config", "base_dir") + start_with = cf.get("config", "ignore_start_with").split("|") + show_file = cf.get("config", "show_file").split('|') + ignore_file_name = cf.get("config", "ignore_file_name").split("|") + + out_file_list = cf.get("outFile", "eachFile").split("|") + create_depth = int(cf.get("outFile", "create_depth")) + + +def check_file_extension(file_path): + """ + 检查文件后缀是否为指定的后缀 + :param file_path: 文件路径 + :return: 如果文件后缀为指定的后缀,返回True;否则返回False + """ + file_extension = splitext(file_path)[1] + if file_extension in show_file: + return True + else: + return False + + +def check_file_name_satified(file_path): + """ + 获取文件名(不包括扩展名) + :param file_path: 文件路径 + :return: 文件名(不包括扩展名) + """ + file_name_with_extension = basename(file_path) + file_name = splitext(file_name_with_extension)[0] + if file_name[0] in start_with or file_name in ignore_file_name: + return False + return True + + +def save_structure(root_dir, base_dir=base_dir, depth=0): + """ + 遍历指定目录及其所有子目录,生成并保存目录结构。 + :param root_dir: 要处理的根目录路径 + :param base_dir: 用来获得root_dir对base_dir的相对路径 + :param depth: 递归深度,文件夹深度 + """ + root = root_dir + dirs = [] + files = [] + for item in listdir(root): + if isdir(join(root, item)): + dirs.append(item) + else: + files.append(item) + subdir_structure = '' + subdir_name = basename(root) + + if depth != 0: + if create_depth == 0: + subdir_structure += "- " + subdir_name + '\n' + else: + subdir_structure += "- [" + subdir_name + "](" + relpath(root, base_dir) + '\)\n' + else: + if create_depth == 0: + subdir_structure += "- " + "首页" + '\n' + else: + subdir_structure += "- [" + "首页" + "](" + relpath(root, base_dir) + '\)\n' + + for file in files: + if check_file_name_satified(join(root, file)): + if check_file_extension(file): + subdir_structure += " " + "- [" + file + "](" + relpath(join(root, file), + base_dir) + ')\n' + + for subdir in dirs: + subdir_path = join(root, subdir) + if check_file_name_satified(subdir_path): + next_struct = save_structure(subdir_path, base_dir, depth + 1) + next_struct = next_struct[:-1] if next_struct.endswith("\n") else next_struct + next_struct = next_struct.replace("\n", "\n ") + "\n" + subdir_structure += " " + next_struct + + back_struct = subdir_structure + if depth == 1: + subdir_structure = "- [" + "返回首页" + "](" + "" + '\?id=main)\n' + subdir_structure + elif depth != 0: + abs_pre_path = abspath(join(root, "..")) + rel_pre_path = relpath(abs_pre_path, base_dir) + subdir_structure = "- [" + "返回上一级" + "](" + rel_pre_path + '\)\n' + subdir_structure + + subdir_structure = subdir_structure.replace('\\', '/') + print("%s : finished" % root_dir) + if create_depth == -1: + for file_name in out_file_list: + with open(join(root, file_name), 'w', encoding="utf-8") as f: + f.write(subdir_structure) + else: + if depth == 0 : + for file_name in out_file_list: + with open(join(root, file_name), 'w', encoding="utf-8") as f: + f.write(subdir_structure) + return back_struct + + +if __name__ == "__main__": + read_config() + save_structure(base_dir, base_dir, 0) + input() diff --git a/blog/generate/config.ini b/blog/generate/config.ini new file mode 100644 index 00000000..eb3e537e --- /dev/null +++ b/blog/generate/config.ini @@ -0,0 +1,16 @@ +[config] +# docsify根目录 +base_dir=E:\gitee\notes +# 忽略以“_”,"."开头的文件,如果要添加新文件,用“|”分隔 +ignore_start_with=_|. +# 只读取".md"格式问价,如果添加新格式,用“|”分隔 +show_file=.md +# 要忽略的文件名,要添加新文件,用“|”分隔 +ignore_file_name=README + + +[outFile] +# 想要在几级目录生成文件,默认"-1"表示所有文件夹生成,"0"表示在根目录生成,可以配合侧边栏折叠插件使用 +create_depth=1 +# 每个文件夹下主页文件名称和侧边栏文件名,默认README.md和_sidebar.md文件,想生成其他名称可修改文字,或者添加用“|”分隔 +eachFile=README.md|_sidebar.md \ No newline at end of file diff --git a/blog/image/b.jpg b/blog/image/b.jpg new file mode 100644 index 00000000..011d95af Binary files /dev/null and b/blog/image/b.jpg differ diff --git a/blog/image/cat.svg b/blog/image/cat.svg new file mode 100644 index 00000000..8dc6b3cf --- /dev/null +++ b/blog/image/cat.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/blog/image/cover1.png b/blog/image/cover1.png new file mode 100644 index 00000000..835201ed Binary files /dev/null and b/blog/image/cover1.png differ diff --git a/blog/image/cover2.jpg b/blog/image/cover2.jpg new file mode 100644 index 00000000..fdb5a23a Binary files /dev/null and b/blog/image/cover2.jpg differ diff --git a/blog/image/p.jpg b/blog/image/p.jpg new file mode 100644 index 00000000..a7dc6aee Binary files /dev/null and b/blog/image/p.jpg differ diff --git a/blog/image/polar_bear.svg b/blog/image/polar_bear.svg new file mode 100644 index 00000000..b26aa342 --- /dev/null +++ b/blog/image/polar_bear.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/index.html b/index.html index 220e8840..d71c0b06 100644 --- a/index.html +++ b/index.html @@ -5,11 +5,23 @@ 通灵诗人的笔记 + + + + + + + + + + + +
@@ -20,17 +32,19 @@ window.$docsify = { // 仓库地址,点击右上角的Github章鱼猫头像会跳转到此地址 repo: 'https://github.com/Estom/notes', // 侧边栏支持,默认加载的是项目根目录下的_sidebar.md文件 - // loadSidebar: true, + loadSidebar: true, // 导航栏支持,默认加载的是项目根目录下的_navbar.md文件 loadNavbar: true, // 封面支持,默认加载的是项目根目录下的_coverpage.md文件 coverpage: true, // 最大支持渲染的标题层级 - maxLevel: 5, + maxLevel: 3, // 自定义侧边栏后默认不会再生成目录,设置生成目录的最大层级(建议配置为2-4) - subMaxLevel: 4, + subMaxLevel: 3, // 小屏设备下合并导航栏到侧边栏 mergeNavbar: true, + // log + // logo: '/blog/image/cat.svg', /*搜索相关设置*/ search: { maxAge: 86400000,// 过期时间,单位毫秒,默认一天 @@ -44,8 +58,65 @@ window.$docsify = { noData: '找不到结果', depth: 4, hideOtherSidebarContent: false, - namespace: 'Docsify-Guide', - } + namespace: '通灵诗人的笔记', + }, + // 字数插件 + count:{ + countable: true, + position: 'top', + margin: '10px', + float: 'right', + fontsize:'0.9em', + color:'rgb(90,90,90)', + language:'chinese', + localization: { + words: "", + minute: "" + }, + isExpected: true + }, + // 分页导航插件 + pagination: { + previousText: '上一篇', + nextText: '下一篇', + crossChapter: true, + crossChapterText: true + }, + // 文本高亮 + 'flexible-alerts': { + style: 'flat', + note: { + label: "信息" + }, + tip: { + label: "提示" + }, + warning: { + label: "注意" + }, + attention: { + label: "切记" + } + }, + sidebarDisplayLevel: 2, + // 页脚信息插件 + loadFooter: true, + loadFooter: '_footer.md', + share: { + reddit: true, + linkedin: true, + facebook: true, + twitter: true, + whatsapp: true, + telegram: true, + }, + // 文章导航样式 + toc: { + scope: '.markdown-section', + headings: 'h1, h2, h3', + title: '文章导航', + }, + } @@ -58,5 +129,26 @@ window.$docsify = { + + + + + + + + + + + + + + + + + + + + +