Add comments
This commit is contained in:
parent
b307eb391b
commit
4de44c7e8c
3 changed files with 388 additions and 6 deletions
|
@ -13,9 +13,20 @@ unit class Config;
|
|||
method generate-post(Int:D $id, Post:D $post, $db) {
|
||||
my $meta = $db.meta;
|
||||
my $content = $post.render-html;
|
||||
my $cactus-script = qq「」
|
||||
document.addEventListener('DOMContentLoaded', () => \{
|
||||
initComments(\{
|
||||
node: document.getElementById("comment-section"),
|
||||
defaultHomeserverUrl: "https://matrix.cactus.chat",
|
||||
serverName: "cactus.chat",
|
||||
siteName: "stranger.systems",
|
||||
commentSectionId: "post-$id"
|
||||
\})\})」;
|
||||
my $head =
|
||||
head [
|
||||
# Generate the universal header components
|
||||
generate-head($meta, $post.title, $post.description);
|
||||
# Open graph tags for embedding
|
||||
meta :property<og:title>, :content($post.title);
|
||||
meta :property<og:url>, :content(post-link-abs $db.meta, $id, $post);
|
||||
meta :property<og:site_name>, :content($db.meta.title);
|
||||
|
@ -26,6 +37,14 @@ method generate-post(Int:D $id, Post:D $post, $db) {
|
|||
$post.tags.map(-> $tag {
|
||||
meta :property<article:tag>, :content($tag)
|
||||
});
|
||||
|
||||
# Cactus comments support
|
||||
link :rel<stylesheet>,
|
||||
:href</resources/cactus.css>,
|
||||
:type<text/css>;
|
||||
script :src<https://gateway.pinata.cloud/ipfs/QmSiWN27KZZ1XE32jKwifBnS3nWTUcFGNArKzur2nmDgoL/v0.13.0/cactus.js>;
|
||||
# Only actually load the script if the post isn't hidden
|
||||
optl !$post.hidden, -> {script $cactus-script};
|
||||
];
|
||||
my $body =
|
||||
body [
|
||||
|
@ -34,8 +53,10 @@ method generate-post(Int:D $id, Post:D $post, $db) {
|
|||
post-header $id, $post, $db;
|
||||
div :class<post-body>, [
|
||||
$content;
|
||||
]
|
||||
]
|
||||
];
|
||||
];
|
||||
# Only actually have the comment section if the post isn't hidden
|
||||
optl !$post.hidden, -> {div :id<comment-section>, :class<comments>};
|
||||
];
|
||||
# TODO: Setup Comments
|
||||
# TODO: Setup footer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue