HITSZ-OpenAuto / hoa-moe

HITSZ OpenAuto Website
https://hoa.moe
MIT License
18 stars 9 forks source link

Add file type support for 'markdown’ #32

Open kowyo opened 8 months ago

kowyo commented 8 months ago

When I edit 'gen_links.py' to add more extension in line 63

from

filtered_paths = [path for path in paths if path.endswith(('.pdf', '.zip', '.rar', '.7z', '.docx', '.doc'))]

to

filtered_paths = [path for path in paths if path.endswith(('.pdf', '.zip', '.rar', '.7z', '.docx', '.doc', '.pptx', '.ppt', '.md'))]

CI reports an error when building course pages:

Traceback (most recent call last):
  File "/home/runner/work/hitsz-openauto.github.io/hitsz-openauto.github.io/scripts/gen_links.py", line 81, in <module>
    save_files_list(owner, repo, username, token)
  File "/home/runner/work/hitsz-openauto.github.io/hitsz-openauto.github.io/scripts/gen_links.py", line 64, in save_files_list
    result_content = create_hugo_shortcode(filtered_paths, owner, repo)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/hitsz-openauto.github.io/hitsz-openauto.github.io/scripts/gen_links.py", line 12, in create_hugo_shortcode
    result += generate_folder_shortcode(directory, content, owner, repo)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/hitsz-openauto.github.io/hitsz-openauto.github.io/scripts/gen_links.py", line 29, in generate_folder_shortcode
    for name, value in content.items():
                       ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'items'
Error: Process completed with exit code 1.

Ref: https://github.com/HITSZ-OpenAuto/hitsz-openauto.github.io/actions/runs/7363824719/job/20043643516

kowyo commented 8 months ago

I have fixed it somehow by excluding .md and .ppt

kowyo commented 5 months ago

生成下载链接的脚本没有正确处理根目录的 Markdown 文件,导致出现报错。