From 65052b865d31ab667fc6861e4c4dcdfbb2835492 Mon Sep 17 00:00:00 2001 From: Emile Bangma Date: Thu, 17 Oct 2024 14:30:25 +0000 Subject: [PATCH] Check null cases --- quartz/components/scripts/comments.inline.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/quartz/components/scripts/comments.inline.ts b/quartz/components/scripts/comments.inline.ts index 038d12d05..e2f7dc033 100644 --- a/quartz/components/scripts/comments.inline.ts +++ b/quartz/components/scripts/comments.inline.ts @@ -26,10 +26,8 @@ const getThemeName = (theme: "light" | "dark") => { if (!giscusContainer) { return theme } - const darkGiscus = - giscusContainer.dataset.darkTheme !== "" ? giscusContainer.dataset.darkTheme : "dark" - const lightGiscus = - giscusContainer.dataset.lightTheme !== "" ? giscusContainer.dataset.lightTheme : "light" + const darkGiscus = giscusContainer.dataset.darkTheme ?? "dark" + const lightGiscus = giscusContainer.dataset.lightTheme ?? "light" return theme === "dark" ? darkGiscus : lightGiscus } @@ -38,9 +36,7 @@ const getThemeUrl = () => { if (!giscusContainer) { return "https://giscus.app" } - return giscusContainer.dataset.themeUrl !== "" - ? giscusContainer.dataset.themeUrl - : "https://giscus.app" + return giscusContainer.dataset.themeUrl ?? "https://giscus.app" } type GiscusElement = Omit & {