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):
|
def generate_context(self):
|
||||||
"""change the context"""
|
"""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 = []
|
all_articles = []
|
||||||
for f in self.get_files(
|
for f in self.get_files(
|
||||||
article_path,
|
article_path,
|
||||||
|
|
@ -259,8 +261,8 @@ class ArticlesGenerator(Generator):
|
||||||
# if no category is set, use the name of the path as a category
|
# if no category is set, use the name of the path as a category
|
||||||
if 'category' not in metadata:
|
if 'category' not in metadata:
|
||||||
|
|
||||||
if os.path.dirname(f) == article_path:
|
if os.path.dirname(f) == article_path: # if the article is not in a subdirectory
|
||||||
category = self.settings['DEFAULT_CATEGORY']
|
category = self.settings['DEFAULT_CATEGORY']
|
||||||
else:
|
else:
|
||||||
category = os.path.basename(os.path.dirname(f))\
|
category = os.path.basename(os.path.dirname(f))\
|
||||||
.decode('utf-8')
|
.decode('utf-8')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue