From a6900908b0aad2dba9facdfc362bbff89d0085ed Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 17 Sep 2023 17:41:09 +0100 Subject: [PATCH] Exclude certain files from output --- hooks/exclude-static.py | 18 ++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 19 insertions(+) create mode 100644 hooks/exclude-static.py diff --git a/hooks/exclude-static.py b/hooks/exclude-static.py new file mode 100644 index 0000000..274aa8a --- /dev/null +++ b/hooks/exclude-static.py @@ -0,0 +1,18 @@ +import fnmatch + +from mkdocs.plugins import event_priority, get_plugin_logger + +EXCLUDED_FILES = { + "*.mmd" +} + +logger = get_plugin_logger("exclude-static") + +@event_priority(100) +def on_files(files, config): + for file in files: + if any(fnmatch.fnmatch(file.url, pattern) for pattern in EXCLUDED_FILES): + logger.debug("Excluding %s", file.url) + files.remove(file) + + return files diff --git a/mkdocs.yml b/mkdocs.yml index cbc793a..a6e0ab3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -20,6 +20,7 @@ hooks: - hooks/kroki.py - hooks/include-file.py - hooks/unsplash.py + - hooks/exclude-static.py markdown_extensions: - attr_list