mirror of
https://github.com/zoo-apps/foundation.git
synced 2026-10-30 14:57:26 +00:00
- Full app extraction from zoo monorepo (source only) - Configured for GitHub Pages deployment - Static export enabled - Custom domain: foundation.zoo.ngo - Excludes node_modules and build artifacts
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
type OpenGraphType = {
|
|
siteName: string;
|
|
description: string;
|
|
templateTitle?: string;
|
|
logo?: string;
|
|
};
|
|
// !STARTERCONF This OG is generated from https://github.com/theodorusclarence/og
|
|
// Please clone them and self-host if your site is going to be visited by many people.
|
|
// Then change the url and the default logo.
|
|
export function openGraph({
|
|
siteName,
|
|
templateTitle,
|
|
description,
|
|
// !STARTERCONF Or, you can use my server with your own logo.
|
|
logo = 'https://og.<your-domain>/images/logo.jpg',
|
|
}: OpenGraphType): string {
|
|
const ogLogo = encodeURIComponent(logo);
|
|
const ogSiteName = encodeURIComponent(siteName.trim());
|
|
const ogTemplateTitle = templateTitle
|
|
? encodeURIComponent(templateTitle.trim())
|
|
: undefined;
|
|
const ogDesc = encodeURIComponent(description.trim());
|
|
|
|
return `https://og.<your-domain>/api/general?siteName=${ogSiteName}&description=${ogDesc}&logo=${ogLogo}${
|
|
ogTemplateTitle ? `&templateTitle=${ogTemplateTitle}` : ''
|
|
}`;
|
|
}
|
|
|
|
export function getFromLocalStorage(key: string): string | null {
|
|
if (typeof window !== 'undefined') {
|
|
return window.localStorage.getItem(key);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function getFromSessionStorage(key: string): string | null {
|
|
if (typeof sessionStorage !== 'undefined') {
|
|
return sessionStorage.getItem(key);
|
|
}
|
|
return null;
|
|
}
|