From 2b49b0415490bd9388eedae2f958335135549efc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 15 Sep 2023 21:09:19 +0100 Subject: [PATCH] Fix tag navigation tree --- hooks/tags.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hooks/tags.py b/hooks/tags.py index 08410ac..64999b2 100644 --- a/hooks/tags.py +++ b/hooks/tags.py @@ -4,7 +4,7 @@ import tempfile import os import shutil -TAGS_TEMP_DIR = os.path.join(tempfile.gettempdir(), "tags") +TAGS_TEMP_DIR = os.path.join(tempfile.gettempdir(), "mkdocs-tags") shutil.rmtree(TAGS_TEMP_DIR, ignore_errors=True) os.mkdir(TAGS_TEMP_DIR) @@ -26,24 +26,26 @@ def on_files(files: Files, config): if found_tag_page: with open(found_tag_page.abs_src_path) as f: content, _ = meta.get_data(f.read()) + + files.remove(found_tag_page) else: content = "" filename = f"{tag}.md" - write_file(template.render(tag=tag, content=content).encode(), os.path.join(TAGS_TEMP_DIR, filename)) + write_file(template.render(tag=tag, content=content).encode(), os.path.join(TAGS_TEMP_DIR, "tags", filename)) files.append(File( - path=filename, + path=f"tags/{filename}", src_dir=TAGS_TEMP_DIR, - dest_dir=os.path.join(config["site_dir"], "tags"), + dest_dir=config["site_dir"], use_directory_urls=True )) - write_file(list_template.render().encode(), os.path.join(TAGS_TEMP_DIR, "tags.md")) + write_file(list_template.render().encode(), os.path.join(TAGS_TEMP_DIR, "tags", "index.md")) files.append(File( - path="tags.md", + path="tags/index.md", src_dir=TAGS_TEMP_DIR, dest_dir=config["site_dir"], use_directory_urls=True