From 30670d998eff81940a3d5ce392737ef62355a0af Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 22 Apr 2022 15:31:08 -0600 Subject: [PATCH] Regenerate paths on each change This is so we can detect new files without having to restart the Pelican server. Computers are fast enough anyway. --- pelican/plugins/obsidian/obsidian.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pelican/plugins/obsidian/obsidian.py b/pelican/plugins/obsidian/obsidian.py index 3a30d34..3fa1e51 100644 --- a/pelican/plugins/obsidian/obsidian.py +++ b/pelican/plugins/obsidian/obsidian.py @@ -97,22 +97,20 @@ def populate_files_and_articles(article_generator): global FILES base_path = Path(article_generator.path) - if not ARTICLES: - articles = base_path.glob('**/*.md') - for article in articles: - full_path, filename_w_ext = os.path.split(article) - filename, ext = os.path.splitext(filename_w_ext) - full_path = str(full_path).replace(str(base_path) + '/', '') - ARTICLES[filename] = full_path + articles = base_path.glob('**/*.md') + for article in articles: + full_path, filename_w_ext = os.path.split(article) + filename, ext = os.path.splitext(filename_w_ext) + full_path = str(full_path).replace(str(base_path) + '/', '') + ARTICLES[filename] = full_path globs = [base_path.glob('**/*.{}'.format(ext)) for ext in ['png', 'jpg', 'svg', 'apkg', 'gif']] files = chain(*globs) - if not FILES: - for _file in files: - full_path, filename_w_ext = os.path.split(_file) - full_path = str(full_path).replace(str(base_path) + '/', '') - FILES[filename_w_ext] = full_path + for _file in files: + full_path, filename_w_ext = os.path.split(_file) + full_path = str(full_path).replace(str(base_path) + '/', '') + FILES[filename_w_ext] = full_path def modify_reader(article_generator):