Skip to content

Instantly share code, notes, and snippets.

@abdelfattahradwan
Created April 24, 2024 17:01
Show Gist options
  • Save abdelfattahradwan/4adcf1f62873521ee3c9af0cf3aee641 to your computer and use it in GitHub Desktop.
Save abdelfattahradwan/4adcf1f62873521ee3c9af0cf3aee641 to your computer and use it in GitHub Desktop.
<script lang="ts">
import { page } from "$app/stores";
export let title: string = "";
export let type: string = "";
export let image: string = "";
export let url: string = $page.url.pathname;
export let description: string = "";
export let siteName: string = "";
export let twitter: string = "";
function getUrl() {
return url.startsWith($page.url.origin) ? url : `${$page.url.origin}${url}`;
}
</script>
<svelte:head>
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<meta property="og:type" content={type} />
<meta property="og:url" content={getUrl()} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={image} />
<meta property="og:site_name" content={siteName} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:url" content={getUrl()} />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={image} />
<meta name="twitter:site" content={twitter} />
<meta name="twitter:creator" content={twitter} />
</svelte:head>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment