HowToCook icon indicating copy to clipboard operation
HowToCook copied to clipboard

目录混乱 + 中文目录

Open simingy opened this issue 2 years ago • 4 comments

mkdocs scan folder生成的HTML index基本上是乱的

可以利用https://www.mkdocs.org/user-guide/writing-your-docs/ 来customize navigation bar

比方说:

nav:
    - README.md
    - 菜谱: dishes/
    - 做菜技巧: tips/
    - CONTRIBUTING.md

Idea:

  • Contributions放在最下面
  • 中文目录 (dishes -> 菜谱)

但是现在mkdocs nav section并不支持folder https://github.com/mkdocs/mkdocs/issues/714

可以写个脚本每次自动生成nav:这个section,或者直接把文件夹名字改成中文

simingy avatar Feb 28 '22 17:02 simingy

能想到德办法就是手动把需要的order添加到nav下面

simingy avatar Mar 01 '22 03:03 simingy

hmm this might be the fix

you have a README.md which already contains your nav order

simingy avatar Mar 01 '22 03:03 simingy

Sorry 我没开issue的notification

我觉得我们可以开发点儿进阶的,用actions自动生成那个yml文件。

Anduin2017 avatar Mar 01 '22 07:03 Anduin2017

安装 lukasgeiter/mkdocs-awesome-pages-plugin: An MkDocs plugin that simplifies configuring page titles and their order 然后用action来运行想要的效果 e.g. :

#!/usr/bin/env bash
# add .pages for certain folders
set -e
# go through folders
for folder in $(ls -d */); do
    # if this folder contains files that start with two or more digits
    if [[ $(ls "$folder" | grep -E '^[0-9]{2,}') ]]; then
        # add .pages to the folder name
        echo "Add .pages to $folder for mkdocs-awesome-pages-plugin"
        echo -e "nav:\n- ...\n$(ls -1 "$folder" | grep -E '([0-9]{2,})' | sed 's/^/- /')" > "$folder"/.pages
        continue # go to next folder
    fi
done

luchaoqi avatar Mar 09 '22 00:03 luchaoqi