Generate series pages
This commit is contained in:
parent
7cf4827d0c
commit
baf8d6556b
8 changed files with 168 additions and 41 deletions
|
@ -10,14 +10,6 @@ use DB::Post;
|
|||
|
||||
unit class Config;
|
||||
|
||||
sub show-html($html) {
|
||||
my $out = "<!doctype html>$html";
|
||||
# Work around HTML::Functional automatically putting newlines between tags
|
||||
$out ~~ s:g/'</i>' \v+ '<span>'/<\/i><span>/;
|
||||
$out ~~ s:g/\v+ '</a>'/<\/a>/;
|
||||
$out
|
||||
}
|
||||
|
||||
# TODO: Support GFM admonitions
|
||||
method generate-post(Int:D $id, Post:D $post, $db) {
|
||||
my $meta = $db.meta;
|
||||
|
@ -45,34 +37,13 @@ method generate-post(Int:D $id, Post:D $post, $db) {
|
|||
show-html $html
|
||||
}
|
||||
|
||||
method generate-blurb(Int:D $id, $db) {
|
||||
my $post = $db.posts{$id};
|
||||
my $desc = $post.description;
|
||||
my $link = post-link $id, $post;
|
||||
div :class<post-blurb>, [
|
||||
div :class<post-blurb-title>, [
|
||||
a :href($link), span [
|
||||
h2 $post.title;
|
||||
];
|
||||
];
|
||||
post-info $id, $post, $db;
|
||||
if $desc ~~ Str:D {
|
||||
div :class<post-blurb-description>, [
|
||||
p $post.description;
|
||||
];
|
||||
} else {
|
||||
[]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
method generate-index($db) {
|
||||
my @most-recent =
|
||||
$db.sorted-posts
|
||||
.head(10)
|
||||
.grep(!*.value.hidden)
|
||||
.map(-> $pair {
|
||||
self.generate-blurb: $pair.key, $db
|
||||
generate-blurb $pair.key, $db
|
||||
});
|
||||
|
||||
my $head = generate-head($db.meta);
|
||||
|
@ -97,7 +68,7 @@ method generate-archive($db) {
|
|||
$db.sorted-posts
|
||||
.grep(!*.value.hidden)
|
||||
.map(-> $pair {
|
||||
self.generate-blurb: $pair.key, $db
|
||||
generate-blurb $pair.key, $db
|
||||
});
|
||||
|
||||
my $head = generate-head($db.meta);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue