mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
More granular control of tags and categories slugs. Fixes #1873
- add TAG_SUBSTITUTIONS AND CATEGORY_SUBSTITURIONS settings - make slugify keep non-alphanumeric characters if configured
This commit is contained in:
parent
70665ea0fa
commit
648165b839
8 changed files with 123 additions and 8 deletions
|
|
@ -112,13 +112,28 @@ class URLWrapper(object):
|
|||
|
||||
|
||||
class Category(URLWrapper):
|
||||
pass
|
||||
@property
|
||||
def slug(self):
|
||||
if self._slug is None:
|
||||
substitutions = self.settings.get('SLUG_SUBSTITUTIONS', ())
|
||||
substitutions += tuple(self.settings.get('CATEGORY_SUBSTITUTIONS',
|
||||
()))
|
||||
self._slug = slugify(self.name, substitutions)
|
||||
return self._slug
|
||||
|
||||
|
||||
class Tag(URLWrapper):
|
||||
def __init__(self, name, *args, **kwargs):
|
||||
super(Tag, self).__init__(name.strip(), *args, **kwargs)
|
||||
|
||||
@property
|
||||
def slug(self):
|
||||
if self._slug is None:
|
||||
substitutions = self.settings.get('SLUG_SUBSTITUTIONS', ())
|
||||
substitutions += tuple(self.settings.get('TAG_SUBSTITUTIONS', ()))
|
||||
self._slug = slugify(self.name, substitutions)
|
||||
return self._slug
|
||||
|
||||
|
||||
class Author(URLWrapper):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue