mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 02:19:08 +03:00
disqus comment system
This commit is contained in:
parent
4d547672cc
commit
a373337aeb
@ -13,10 +13,10 @@ Personal website created with Astro.
|
|||||||
- [x] Multilang web-site
|
- [x] Multilang web-site
|
||||||
- [x] Prefetch pages via [Quicklink](https://getquick.link/)
|
- [x] Prefetch pages via [Quicklink](https://getquick.link/)
|
||||||
- [x] Form handling via [Netlify Forms](https://www.netlify.com/products/forms/)
|
- [x] Form handling via [Netlify Forms](https://www.netlify.com/products/forms/)
|
||||||
- [x] Comment system via [utterances](https://utteranc.es/)
|
- [x] Comment system via [Disqus](https://disqus.com/)
|
||||||
- [x] RSS Feed for articles
|
- [x] RSS Feed for articles
|
||||||
- [x] SEO optimized
|
- [x] SEO optimized
|
||||||
- [x] Views counter
|
- [x] Views counter
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@ -1,29 +1,43 @@
|
|||||||
---
|
---
|
||||||
import UIString from "../UIString";
|
interface Props {
|
||||||
|
url: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { url, id } = Astro.props as Props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer>
|
<footer itemscope itemtype="http://schema.org/UserComments">
|
||||||
<h2><UIString key={"articlePost.comments"} /></h2>
|
<div id="disqus_thread"></div>
|
||||||
<div id="comments"></div>
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script>
|
<script define:vars={{ url, id }}>
|
||||||
const $commentsWrapper = document.getElementById("comments");
|
var disqus_config = function () {
|
||||||
const $commentsScript = document.createElement("script");
|
this.page.url = url;
|
||||||
|
this.page.identifier = id;
|
||||||
|
};
|
||||||
|
|
||||||
$commentsScript.async = true;
|
var e = document.getElementById("disqus_thread");
|
||||||
$commentsScript.src = "https://utteranc.es/client.js";
|
if ("IntersectionObserver" in window) {
|
||||||
$commentsScript.setAttribute("repo", "sergeyyarkov/comments");
|
var t = new IntersectionObserver((e) => {
|
||||||
$commentsScript.setAttribute("issue-term", "title");
|
e.forEach((e) => {
|
||||||
$commentsScript.setAttribute("label", "Comment");
|
e.isIntersecting &&
|
||||||
$commentsScript.setAttribute("id", "utterances");
|
((function () {
|
||||||
$commentsScript.setAttribute("crossorigin", "anonymous");
|
var e = document,
|
||||||
|
t = e.createElement("script");
|
||||||
if (window.theme) {
|
(t.src = "https://yarkov-tech.disqus.com/embed.js"),
|
||||||
$commentsScript.setAttribute("theme", window.theme === "dark" ? "dark-blue" : "github-light");
|
t.setAttribute("data-timestamp", +new Date()),
|
||||||
} else {
|
(e.head || e.body).appendChild(t);
|
||||||
$commentsScript.setAttribute("theme", "github-light");
|
})(),
|
||||||
|
t.unobserve(e.target));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
t.observe(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($commentsWrapper) $commentsWrapper.appendChild($commentsScript);
|
window.addEventListener(
|
||||||
|
"onthemetoggled",
|
||||||
|
() =>
|
||||||
|
document.readyState == "complete" && setTimeout(() => DISQUS.reset({ reload: true, config: disqus_config }), 100)
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const { data, lang } = Astro.props as Props;
|
const { data, lang } = Astro.props as Props;
|
||||||
|
const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
|
||||||
const { slug, title, description, coverImage, tags, author, published_at } = data;
|
const { slug, title, description, coverImage, tags, author, published_at } = data;
|
||||||
const t = useTranslation(Astro);
|
const t = useTranslation(Astro);
|
||||||
---
|
---
|
||||||
@ -73,7 +74,7 @@ const t = useTranslation(Astro);
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<slot />
|
<slot />
|
||||||
<ArticleComments />
|
<ArticleComments url={canonicalUrl.href} id={data.slug} />
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<script define:vars={{ slug }}>
|
<script define:vars={{ slug }}>
|
||||||
|
|||||||
@ -144,4 +144,11 @@
|
|||||||
& body > main svg:not([data-filter="none"]) {
|
& body > main svg:not([data-filter="none"]) {
|
||||||
filter: var(--icon-filter);
|
filter: var(--icon-filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
https://sergeyski.com/css-color-scheme-and-iframes-lessons-learned-from-disqus-background-bug/
|
||||||
|
*/
|
||||||
|
iframe[src*="disqus.com"] {
|
||||||
|
color-scheme: light;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user