-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate_post_view.php
44 lines (39 loc) · 1.57 KB
/
template_post_view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<h1 class="marked-inline"><?= htmlspecialchars($title); ?></h1>
<?php if (isLoggedIn()) : ?>
<p>
[<a href="<?= getPostEditURL($post->id) ?>">Edit</a>]
[<a href="<?= getPostDeleteURL($post->id) ?>" onclick="return confirm('Are you sure?')">Delete</a>]
</p>
<?php endif; ?>
<script>
document.addEventListener("DOMContentLoaded", (event) => {
const content = <?= json_encode($post->content) ?>;
const contentPre = document.getElementById("content");
const renderedContentDiv = document.getElementById("renderedContent");
renderedContentDiv.innerHTML = marked.parse(content);
contentPre.style.display = "none";
});
</script>
<pre id="content"><?= htmlspecialchars($post->content) ?></pre>
<div class="post-content" id="renderedContent"></div>
<small class="post-metadata">
Created: <?= $post->createdAt ?>, Updated: <?= $post->updatedAt ?>, ID: <?= $post->id ?>
</small>
<?php if (isset($config['giscus_repo'])): ?>
<script src="https://giscus.app/client.js"
data-repo="<?= $config['giscus_repo'] ?>"
data-repo-id="<?= $config['giscus_repo_id'] ?>"
data-category="<?= $config['giscus_category'] ?>"
data-category-id="<?= $config['giscus_category_id'] ?>"
data-mapping="specific"
data-term="<?= htmlentities($post->id) ?>"
data-strict="0"
data-reactions-enabled="0"
data-emit-metadata="0"
data-input-position="bottom"
data-theme="gruvbox_light"
data-lang="en"
crossorigin="anonymous"
async>
</script>
<?php endif; ?>