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.
main
Tanner Collin 2 years ago
parent d3735aa826
commit 30670d998e
  1. 22
      pelican/plugins/obsidian/obsidian.py

@ -97,22 +97,20 @@ def populate_files_and_articles(article_generator):
global FILES global FILES
base_path = Path(article_generator.path) base_path = Path(article_generator.path)
if not ARTICLES: articles = base_path.glob('**/*.md')
articles = base_path.glob('**/*.md') for article in articles:
for article in articles: full_path, filename_w_ext = os.path.split(article)
full_path, filename_w_ext = os.path.split(article) filename, ext = os.path.splitext(filename_w_ext)
filename, ext = os.path.splitext(filename_w_ext) full_path = str(full_path).replace(str(base_path) + '/', '')
full_path = str(full_path).replace(str(base_path) + '/', '') ARTICLES[filename] = full_path
ARTICLES[filename] = full_path
globs = [base_path.glob('**/*.{}'.format(ext)) for ext in ['png', 'jpg', 'svg', 'apkg', 'gif']] globs = [base_path.glob('**/*.{}'.format(ext)) for ext in ['png', 'jpg', 'svg', 'apkg', 'gif']]
files = chain(*globs) files = chain(*globs)
if not FILES: for _file in files:
for _file in files: full_path, filename_w_ext = os.path.split(_file)
full_path, filename_w_ext = os.path.split(_file) full_path = str(full_path).replace(str(base_path) + '/', '')
full_path = str(full_path).replace(str(base_path) + '/', '') FILES[filename_w_ext] = full_path
FILES[filename_w_ext] = full_path
def modify_reader(article_generator): def modify_reader(article_generator):

Loading…
Cancel
Save