mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
allow override page url and save_as values directly from the metadata
this is similar to the template override implemented in #404
This commit is contained in:
parent
9f66333d77
commit
a5772bf3d6
1 changed files with 4 additions and 0 deletions
|
|
@ -44,6 +44,8 @@ class Page(object):
|
|||
|
||||
# set metadata as attributes
|
||||
for key, value in local_metadata.items():
|
||||
if key in ('save_as', 'url'):
|
||||
key = 'override_' + key
|
||||
setattr(self, key.lower(), value)
|
||||
|
||||
# also keep track of the metadata attributes available
|
||||
|
|
@ -128,6 +130,8 @@ class Page(object):
|
|||
return self.settings[fq_key].format(**self.url_format)
|
||||
|
||||
def get_url_setting(self, key):
|
||||
if hasattr(self, 'override_' + key):
|
||||
return getattr(self, 'override_' + key)
|
||||
key = key if self.in_default_lang else 'lang_%s' % key
|
||||
return self._expand_settings(key)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue