mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Optional post id attribute.
Implement an optional `id` attribute on posts, that can be used to override the default feed unique-id generation. Useful if you have an old feed with a different format of ids, or ever need to rename a post without it showing up as a duplicate in everyones feed.
This commit is contained in:
parent
932407f153
commit
447cb7583b
1 changed files with 8 additions and 2 deletions
|
|
@ -35,11 +35,17 @@ class Writer(object):
|
|||
def _add_item_to_the_feed(self, feed, item):
|
||||
|
||||
title = Markup(item.title).striptags()
|
||||
if hasattr(item, 'id'):
|
||||
unique_id = item.id
|
||||
else:
|
||||
unique_id = ('tag:%s,%s:%s'
|
||||
% (self.site_url.replace('http://', ''),
|
||||
item.date.date(),
|
||||
item.url))
|
||||
feed.add_item(
|
||||
title=title,
|
||||
link='%s/%s' % (self.site_url, item.url),
|
||||
unique_id='tag:%s,%s:%s' % (self.site_url.replace('http://', ''),
|
||||
item.date.date(), item.url),
|
||||
unique_id=unique_id,
|
||||
description=item.get_content(self.site_url),
|
||||
categories=item.tags if hasattr(item, 'tags') else None,
|
||||
author_name=getattr(item, 'author', ''),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue