Skip to content

Commit

Permalink
fix(blog): local local storage after load
Browse files Browse the repository at this point in the history
  • Loading branch information
alomerry committed Feb 14, 2024
1 parent b310eb5 commit 92e6ad1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
38 changes: 14 additions & 24 deletions blog/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions blog/src/alomerry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export function formatDateByAlomerry(d: string | Date, onlyDate = true) {

const DISPLAY_COMMENT = "display_comment";

export const ALOMERRY_BLOG_DOMAIN="blog.alomerry.com"
export const ALOMERRY_BLOG_WALINE_DOMAIN="https://waline-blog.alomerry.com"
export const ALOMERRY_BLOG_DOMAIN = "blog.alomerry.com";
export const ALOMERRY_BLOG_WALINE_DOMAIN = "https://waline-blog.alomerry.com";

export function displayComment(): boolean {
return getLocalStorage(DISPLAY_COMMENT) === "true";
Expand All @@ -20,9 +20,11 @@ export function setDefaultDisplayComment(displayComment: boolean) {
}

function getLocalStorage(key: string): any {
return localStorage.getItem(key);
return typeof localStorage === "undefined" ? null : localStorage.getItem(key);
}

function setLocalStorage(key: string, value: string) {
return localStorage.setItem(key, value);
if (typeof localStorage !== "undefined") {
localStorage?.setItem(key, value);
}
}

0 comments on commit 92e6ad1

Please sign in to comment.