forked from github/pelican
Add the EXTRA_PATH_METADATA setting
Useful for altering static output paths when you don't want to encode extra metadata in the static file's source path.
This commit is contained in:
parent
1ca0e06a27
commit
d43dc1b9d6
3 changed files with 8 additions and 3 deletions
|
|
@ -64,6 +64,7 @@ Setting name (default value) What doe
|
|||
``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``.
|
||||
`PATH_METADATA` (``''``) Like ``FILENAME_METADATA``, but parsed from a page's
|
||||
full path relative to the content source directory.
|
||||
`EXTRA_PATH_METADATA` (``{}``) Extra metadata dictionaries keyed by relative path.
|
||||
`DELETE_OUTPUT_DIRECTORY` (``False``) Delete the output directory, and **all** of its contents, before
|
||||
generating new files. This can be useful in preventing older,
|
||||
unnecessary files from persisting in your output. However, **this is
|
||||
|
|
|
|||
|
|
@ -413,9 +413,12 @@ def default_metadata(settings=None, process=None):
|
|||
|
||||
def path_metadata(full_path, source_path, settings=None):
|
||||
metadata = {}
|
||||
if settings and settings.get('DEFAULT_DATE', None) == 'fs':
|
||||
metadata['date'] = datetime.datetime.fromtimestamp(
|
||||
os.stat(path).st_ctime)
|
||||
if settings:
|
||||
if settings.get('DEFAULT_DATE', None) == 'fs':
|
||||
metadata['date'] = datetime.datetime.fromtimestamp(
|
||||
os.stat(full_path).st_ctime)
|
||||
metadata.update(settings.get('EXTRA_PATH_METADATA', {}).get(
|
||||
source_path, {}))
|
||||
return metadata
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ DEFAULT_CONFIG = {
|
|||
'DEFAULT_METADATA': (),
|
||||
'FILENAME_METADATA': '(?P<date>\d{4}-\d{2}-\d{2}).*',
|
||||
'PATH_METADATA': '',
|
||||
'EXTRA_PATH_METADATA': {},
|
||||
'DEFAULT_STATUS': 'published',
|
||||
'ARTICLE_PERMALINK_STRUCTURE': '',
|
||||
'TYPOGRIFY': False,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue