Skip to content

Commit

Permalink
refactor: re-use query result
Browse files Browse the repository at this point in the history
  • Loading branch information
rqbazan committed Nov 19, 2024
1 parent a5b99db commit bce80b6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/layouts/default/components/seo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ const canonicalUrl = getCanonicalUrl(Astro.url);
<script is:inline>
const { STORAGE_KEY, CUSTOM_EVENT_NAME, DARK } = __COLOR_MODE__;

const themeColorEl = document.querySelector("meta[name=theme-color]");

function onColorModeChange(colorMode) {
document
.querySelector("meta[name=theme-color]")
.setAttribute("content", colorMode === DARK ? "#101010" : "#FFF6E3");
const newContent = colorMode === DARK ? "#101010" : "#FFF6E3";
themeColorEl.setAttribute("content", newContent);
}

document.addEventListener(CUSTOM_EVENT_NAME, (e) => {
Expand Down

0 comments on commit bce80b6

Please sign in to comment.