2022-08-02 14:05:56 -04:00
{{ define "main" }}
2022-08-03 13:38:47 -04:00
< h2 > {{ .Title }}< / h2 >
2022-11-21 14:38:40 -05:00
{{ if in .File.Dir "blog" }}
2022-11-16 10:50:25 -05:00
< p >
Posted on
< time datetime = "{{ .Page.Lastmod.Format " Mon Jan 10 17:13:38 2020 -0700 " } } " class = "text-muted" >
{{ $.Date.Format "January 02, 2006" }}
< / time >
(Updated on
< time datetime = "{{ .Page.Lastmod.Format " Mon Jan 10 17:13:38 2020 -0700 " } } " class = "text-muted" >
{{ $.Page.Lastmod.Format "January 02, 2006" }}
< / time > )
< / p >
2022-11-21 14:38:40 -05:00
{{ end }}
2022-08-02 14:05:56 -04:00
2022-09-26 11:07:29 -04:00
< div >
2022-08-03 13:38:47 -04:00
{{ .Content }}
2022-09-22 12:25:08 -04:00
< / div >
2022-09-12 10:53:34 -04:00
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
< h3 > See Also< / h3 >
< ul >
{{ range . }}
< li > < a href = "{{ .RelPermalink }}" > {{ .Title }}< / a > < / li >
{{ end }}
< / ul >
{{ end }}
2022-09-22 12:23:22 -04:00
2022-12-04 07:40:57 -05:00
{{ if in .File.Dir "blog" }}
2022-12-04 07:33:37 -05:00
< h3 > Comments< / h3 >
2022-12-04 06:58:50 -05:00
< script
data-isso="//comments.redstrate.com/"
2022-12-04 07:33:37 -05:00
data-isso-title=""
2022-12-04 06:58:50 -05:00
data-isso-avatar="false"
data-isso-vote="false"
data-isso-reveal-on-click="5"
2022-12-20 19:50:17 -05:00
src="//comments.redstrate.com/js/embed.min.js" crossorigin async>< / script >
2022-12-04 06:55:18 -05:00
2022-12-04 07:40:57 -05:00
< section id = "isso-thread" data-title = "{{ .Title }}" data-isso-id = "{{ .File.ContentBaseName }}" >
2022-12-04 06:55:18 -05:00
< noscript > Javascript needs to be activated to view comments.< / noscript >
< / section >
2022-12-04 07:40:57 -05:00
{{ end }}
2022-12-04 06:55:18 -05:00
2022-09-22 12:23:22 -04:00
{{ with .Params.comments }}
2022-12-04 07:33:37 -05:00
< h3 > Mastodon Comments< / h3 >
2022-09-22 12:23:22 -04:00
< p > I < a href = "https://{{ .host }}/@{{ .username }}/{{ .id }}" > posted this< / a > to my Mastodon! You can use any Fediverse account (Mastodon, Pleroma, etc) to < a class = "button" href = "https://{{ .host }}/interact/{{ .id }}?type=reply" > reply< / a > .< / p >
< p id = "mastodon-comments-list" > < button id = "load-comment" > Load comments< / button > < / p >
< noscript > < p > You need JavaScript to view the comments.< / p > < / noscript >
{{ $domscript := resources.Get "js/purify.min.js" }}
< script src = "{{ $domscript.Permalink }}" type = "text/javascript" > < / script >
< script type = "text/javascript" >
function escapeHtml(unsafe) {
return unsafe
.replace(/& /g, "& ")
.replace(/< /g, "< ")
.replace(/>/g, "> ")
.replace(/"/g, "" ")
.replace(/'/g, "' ");
}
document.getElementById("load-comment").addEventListener("click", function() {
document.getElementById("load-comment").innerHTML = "Loading";
fetch('https://{{ .host }}/api/v1/statuses/{{ .id }}/context')
.then(function(response) {
return response.json();
})
.then(function(data) {
if(data['descendants'] & &
Array.isArray(data['descendants']) & &
data['descendants'].length > 0) {
document.getElementById('mastodon-comments-list').innerHTML = "";
data['descendants'].forEach(function(reply) {
reply.account.display_name = escapeHtml(reply.account.display_name);
reply.account.emojis.forEach(emoji => {
reply.account.display_name = reply.account.display_name.replace(`:${emoji.shortcode}:`,
`< img src = "${escapeHtml(emoji.static_url)}" alt = "Emoji ${emoji.shortcode}" height = "20" width = "20" / > `);
});
mastodonComment =
`< div class = "mastodon-comment" >
< div class = "avatar" >
< img src = "${escapeHtml(reply.account.avatar_static)}" height = 60 width = 60 alt = "" >
< / div >
< div class = "content" >
< div class = "author" >
< a href = "${reply.account.url}" rel = "nofollow" >
< span > ${reply.account.display_name}< / span >
< span class = "disabled" > ${escapeHtml(reply.account.acct)}< / span >
< / a >
< a class = "date" href = "${reply.uri}" rel = "nofollow" >
${reply.created_at.substr(0, 10)}
< / a >
< / div >
< div class = "mastodon-comment-content" > ${reply.content}< / div >
< / div >
< / div > `;
document.getElementById('mastodon-comments-list').appendChild(DOMPurify.sanitize(mastodonComment, {'RETURN_DOM_FRAGMENT': true}));
});
} else {
document.getElementById('mastodon-comments-list').innerHTML = "< p > Not comments found< / p > ";
}
});
});
< / script >
{{ end }}
2022-08-02 14:05:56 -04:00
{{ end }}