mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Allow directories in EXTRA_PATH_METADATA
Metadata applied to a directory will apply to all files under it. In case of conflicts, child paths beat parent paths, so metadata applied to `dir/subdir/file.md` will take precedence over that applied to `dir/subdir`, which will take precedence over just `dir`.
This commit is contained in:
parent
e967988eff
commit
ce9f3d55a3
3 changed files with 48 additions and 3 deletions
|
|
@ -273,6 +273,38 @@ class RstReaderTest(ReaderTest):
|
|||
}
|
||||
self.assertDictHasSubset(page.metadata, expected)
|
||||
|
||||
def test_article_extra_path_metadata_recurse(self):
|
||||
parent = "TestCategory"
|
||||
notparent = "TestCategory/article"
|
||||
path = "TestCategory/article_without_category.rst"
|
||||
|
||||
epm = {
|
||||
parent: {'epmr_inherit': parent,
|
||||
'epmr_override': parent, },
|
||||
notparent: {'epmr_bogus': notparent},
|
||||
path: {'epmr_override': path, },
|
||||
}
|
||||
expected_metadata = {
|
||||
'epmr_inherit': parent,
|
||||
'epmr_override': path,
|
||||
}
|
||||
|
||||
page = self.read_file(path=path, EXTRA_PATH_METADATA=epm)
|
||||
self.assertDictHasSubset(page.metadata, expected_metadata)
|
||||
|
||||
# Make sure vars aren't getting "inherited" by mistake...
|
||||
path = "article.rst"
|
||||
page = self.read_file(path=path, EXTRA_PATH_METADATA=epm)
|
||||
for k in expected_metadata.keys():
|
||||
self.assertNotIn(k, page.metadata)
|
||||
|
||||
# Same, but for edge cases where one file's name is a prefix of
|
||||
# another.
|
||||
path = "TestCategory/article_without_category.rst"
|
||||
page = self.read_file(path=path, EXTRA_PATH_METADATA=epm)
|
||||
for k in epm[notparent].keys():
|
||||
self.assertNotIn(k, page.metadata)
|
||||
|
||||
def test_typogrify(self):
|
||||
# if nothing is specified in the settings, the content should be
|
||||
# unmodified
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue