This commit is contained in:
Sergey Yarkov 2023-02-13 23:06:04 +03:00
parent 2dbf994ec6
commit d0f6e50f99
No known key found for this signature in database
GPG Key ID: E91CE1FABC619B6F
2 changed files with 14 additions and 0 deletions

3
.gitignore vendored
View File

@ -19,3 +19,6 @@ pnpm-debug.log*
# macOS-specific files # macOS-specific files
.DS_Store .DS_Store
# Local Netlify folder
.netlify

View File

@ -80,3 +80,14 @@ const {
<slot /> <slot />
<ArticleComments url={canonicalUrl.href} id={slug} /> <ArticleComments url={canonicalUrl.href} id={slug} />
</article> </article>
<script define:vars={{ slug }}>
(async () => {
const response = await fetch(`/api/views?slug=${slug}`, { method: "POST" });
if (!response.ok) return;
const views = await response.text();
const $views = document.getElementById("views");
if (isNaN(parseInt(views, 10))) return;
if ($views) $views.textContent = views;
})();
</script>