-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add viewport meta tag to improve page layout
- Loading branch information
Showing
4 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const CACHE_KEY = 'entryCache'; | ||
const CACHE_EXPIRATION = 24 * 60 * 60 * 1000; // 24 hours in milliseconds | ||
|
||
export const getCache = () => { | ||
if (typeof window === 'undefined' || typeof localStorage === 'undefined') { | ||
return { aliases: {}, parents: {} }; // Check for client-side and localStorage | ||
} | ||
const cache = localStorage.getItem(CACHE_KEY); | ||
if (cache) { | ||
const parsedCache = JSON.parse(cache); | ||
if (Date.now() - parsedCache.timestamp < CACHE_EXPIRATION) { | ||
return parsedCache.data; | ||
} | ||
} | ||
return { aliases: {}, parents: {} }; | ||
}; | ||
|
||
export const setCache = (data: any) => { | ||
if (typeof window === 'undefined' || typeof localStorage === 'undefined') | ||
return; // Check for client-side and localStorage | ||
const cache = { | ||
timestamp: Date.now(), | ||
data, | ||
}; | ||
localStorage.setItem(CACHE_KEY, JSON.stringify(cache)); | ||
}; | ||
|
||
export const appendCache = (id: string, entry: any, isAlias: boolean) => { | ||
const cache = getCache(); | ||
if (isAlias) { | ||
cache.aliases[id] = entry; | ||
} else { | ||
cache.parents[id] = entry; | ||
} | ||
setCache(cache); | ||
}; | ||
|
||
export const invalidateCache = (id: string, isAlias: boolean) => { | ||
const cache = getCache(); | ||
if (isAlias) { | ||
delete cache.aliases[id]; | ||
} else { | ||
delete cache.parents[id]; | ||
} | ||
}; |