mirror of
https://github.com/getpelican/pelican.git
synced 2026-06-04 17:56:55 +02:00
Don't ignore article categories when CATEGORY_SAVE_AS is false
Fixes: #3596 Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
This commit is contained in:
parent
3c69dc68d2
commit
4b8ea9497b
2 changed files with 13 additions and 1 deletions
|
|
@ -811,7 +811,7 @@ def parse_path_metadata(source_path, settings=None, process=None):
|
|||
checks = []
|
||||
for key, data in [("FILENAME_METADATA", base), ("PATH_METADATA", source_path)]:
|
||||
checks.append((settings.get(key, None), data))
|
||||
if settings.get("USE_FOLDER_AS_CATEGORY") and settings.get("CATEGORY_SAVE_AS"):
|
||||
if settings.get("USE_FOLDER_AS_CATEGORY"):
|
||||
checks.append(("(?P<category>.*)", subdir))
|
||||
for regexp, data in checks:
|
||||
if regexp and data:
|
||||
|
|
|
|||
|
|
@ -139,6 +139,18 @@ class DefaultReaderTest(ReaderTest):
|
|||
extra={"limit_msg": "Other images have empty alt attributes"},
|
||||
)
|
||||
|
||||
def test_path_metadata_categories(self):
|
||||
nested_content_path = os.path.join(CUR_DIR, "nested_content")
|
||||
r = readers.Readers(
|
||||
settings=get_settings(USE_FOLDER_AS_CATEGORY=True, CATEGORY_SAVE_AS=None)
|
||||
)
|
||||
mainpage = r.read_file(base_path=nested_content_path, path="maindir/maindir.md")
|
||||
self.assertDictHasSubset(mainpage.metadata, {"category": "maindir"})
|
||||
subpage = r.read_file(
|
||||
base_path=nested_content_path, path="maindir/subdir/subdir.md"
|
||||
)
|
||||
self.assertDictHasSubset(subpage.metadata, {"category": "subdir"})
|
||||
|
||||
|
||||
class RstReaderTest(ReaderTest):
|
||||
def test_article_with_metadata(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue