mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Trailing slashes removed to avoid category bug
This commit is contained in:
parent
1779b66f10
commit
0444513e90
1 changed files with 5 additions and 3 deletions
|
|
@ -245,7 +245,9 @@ class ArticlesGenerator(Generator):
|
|||
def generate_context(self):
|
||||
"""change the context"""
|
||||
|
||||
article_path = os.path.join(self.path, self.settings['ARTICLE_DIR'])
|
||||
article_path = os.path.normpath( # we have to remove trailing slashes
|
||||
os.path.join(self.path, self.settings['ARTICLE_DIR'])
|
||||
)
|
||||
all_articles = []
|
||||
for f in self.get_files(
|
||||
article_path,
|
||||
|
|
@ -259,8 +261,8 @@ class ArticlesGenerator(Generator):
|
|||
# if no category is set, use the name of the path as a category
|
||||
if 'category' not in metadata:
|
||||
|
||||
if os.path.dirname(f) == article_path:
|
||||
category = self.settings['DEFAULT_CATEGORY']
|
||||
if os.path.dirname(f) == article_path: # if the article is not in a subdirectory
|
||||
category = self.settings['DEFAULT_CATEGORY']
|
||||
else:
|
||||
category = os.path.basename(os.path.dirname(f))\
|
||||
.decode('utf-8')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue