Initial tags support
This commit is contained in:
parent
f8c575caac
commit
f1515aab06
2 changed files with 36 additions and 1 deletions
|
@ -41,6 +41,12 @@ sub post-to-item(BlogMeta:D $meta, Int:D $id, Post:D $post --> XML::Element) {
|
|||
XML::Element.new(:name<link>, :attribs({:href($link), :rel<alternate>}));
|
||||
$xml.append:
|
||||
XML::Element.new(:name<summary>, :nodes([$desc])) if $desc;
|
||||
if $post.tags {
|
||||
for $post.tags -> $tag {
|
||||
$xml.append:
|
||||
XML::Element.new(:name<category>, :attribs({:term($tag)}));
|
||||
}
|
||||
}
|
||||
|
||||
$xml
|
||||
}
|
||||
|
|
|
@ -149,12 +149,41 @@ method post-read-time(Post:D $post) {
|
|||
]
|
||||
}
|
||||
|
||||
method post-tag(Str:D $tag) {
|
||||
span :class<post-tag>, [
|
||||
a :href("/tags/$tag.html"), [
|
||||
icon 'hash';
|
||||
$tag;
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
method post-tags(Post:D $post){
|
||||
sub intersperse (\element, +list) {
|
||||
gather for list {
|
||||
FIRST .take, next;
|
||||
take slip element, $_;
|
||||
}
|
||||
}
|
||||
my @tags = $post.tags;
|
||||
if @tags {
|
||||
@tags.=map(-> $tag {self.post-tag($tag)});
|
||||
div :class<post-tags>, [
|
||||
icon 'purchase-tag';
|
||||
' ';
|
||||
intersperse(', ', @tags);
|
||||
]
|
||||
} else {
|
||||
[]
|
||||
}
|
||||
}
|
||||
|
||||
method post-info(Post:D $post) {
|
||||
div :class<post-info>, [
|
||||
self.post-date: $post;
|
||||
self.post-edit: $post;
|
||||
self.post-read-time: $post;
|
||||
# TODO: Add tags once we have support for that
|
||||
self.post-tags: $post;
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue