Skip to content

Commit

Permalink
chore: avoid load artalk when at homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsang4 committed Jan 31, 2024
1 parent d4c652f commit 18accb1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/components/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ export const Comments = (props: Props) => {

useEffect(() => {
const initComment = async () => {
const getArtalkSingleton = await window.getArtalkSingleton
const artalk = getArtalkSingleton({
import("artalk/dist/Artalk.css")
const { init } = await import("artalk")
const artalk = init({
el: "#comments",
pageKey,
pageTitle,
server: commentServer,
site: SITE.title,
})
window.artalk = artalk
const theme = localStorage.getItem("theme") as string
artalk.setDarkMode(theme === "dark")
}
Expand Down
11 changes: 0 additions & 11 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ const socialImageURL = new URL(
</div>
)
}
<script>
const loadArtalk = async () => {
const { init } = await import("artalk")
return (config: any) => {
const artalk = init(config)
window.artalk = artalk
return artalk
}
}
window.getArtalkSingleton = loadArtalk()
</script>
{
import.meta.env.UMAMI_URL && (
<script
Expand Down
1 change: 0 additions & 1 deletion src/layouts/PostDetails.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import "artalk/dist/Artalk.css"
import Layout from "@layouts/Layout.astro"
import Header from "@components/Header.astro"
import Footer from "@components/Footer.astro"
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ export type SocialMedia =
declare global {
interface Window {
artalk: Artalk
getArtalkSingleton: Promise<(config: Partial<ArtalkConfig>) => Artalk>
}
}

0 comments on commit 18accb1

Please sign in to comment.