mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 18:39:14 +03:00
views
This commit is contained in:
parent
2dbf994ec6
commit
d0f6e50f99
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,3 +19,6 @@ pnpm-debug.log*
|
|||||||
|
|
||||||
# macOS-specific files
|
# macOS-specific files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Local Netlify folder
|
||||||
|
.netlify
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user