Skip to content

Commit

Permalink
fix(gen index): 子目录没有任何内容也在索引里的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shlu committed Dec 23, 2024
1 parent 481eb50 commit b91034f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions generate_directory_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def generate_markdown_index(base_path, current_path='.', level=0, exclude_dirs=N
markdown += generate_markdown_index(base_path, relative_path, level + 1, exclude_dirs)
else:
indent = ' ' * level
# 不包含 README.md 的目录,仅显示目录名称,不包含链接
markdown += f"{indent}- 📁 {item}/\n"
# 递归查找子目录
markdown += generate_markdown_index(base_path, relative_path, level + 1, exclude_dirs)
sub=generate_markdown_index(base_path, relative_path, level + 1, exclude_dirs)
if sub and sub != "":
# 不包含 README.md 的目录,仅显示目录名称,不包含链接,并且需要在子目录有内容的情况下才显示
markdown += f"{indent}- 📁 {item}/\n"
markdown += sub
elif os.path.isfile(item_path) and is_markdown_file(item) and item.lower() != 'readme.md':
indent = ' ' * level
# 文件名不包含后缀
Expand Down

0 comments on commit b91034f

Please sign in to comment.