Skip to content

Commit

Permalink
Added meta component
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinmcfarland committed Nov 1, 2024
1 parent f8a4f58 commit 1e0834a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
51 changes: 51 additions & 0 deletions packages/website/src/components/Meta.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<script lang="ts">
// Define optional props without default values
export let title: string | undefined = undefined;
export let description: string | undefined = undefined;
export let url: string | undefined = undefined;
export let image: string | undefined = undefined;
export let type: string | undefined = undefined;
</script>

<svelte:head>
<!-- Primary Meta Tags -->
{#if title}
<meta name="title" content={title} />
{/if}
{#if description}
<meta name="description" content={description} />
{/if}

<!-- Open Graph / Facebook -->
{#if url}
<meta property="og:url" content={url} />
{/if}
{#if title}
<meta property="og:title" content={title} />
{/if}
{#if description}
<meta property="og:description" content={description} />
{/if}
{#if image}
<meta property="og:image" content={image} />
{/if}

{#if type}
<meta property="og:type" content={type} />
{/if}

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
{#if url}
<meta property="twitter:url" content={url} />
{/if}
{#if title}
<meta property="twitter:title" content={title} />
{/if}
{#if description}
<meta property="twitter:description" content={description} />
{/if}
{#if image}
<meta property="twitter:image" content={image} />
{/if}
</svelte:head>
12 changes: 6 additions & 6 deletions packages/website/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import Card from '@/components/Card.svelte';
import Code from '@/components/Code.svelte';
import Icon from '@/components/Icon.svelte';
import Meta from '@/components/Meta.svelte';
import Section from '@/components/Section.svelte';
</script>

<svelte:head>
<title>Plugma — Take Figma plugin development to the next level</title>
<meta property="og:title" content="Plugma: Take Figma plugin development to the next level" />
<meta
property="og:description"
content="Excelerate your plugin develop with an all in one solution for developing and bundling Figma plugins."
<Meta
title="Plugma: Take Figma plugin development to the next level"
description="Excelerate your plugin develop with an all in one solution for developing and bundling Figma plugins."
url={`https://plugma.dev${$page.url.pathname}`}
type="website"
/>
<meta property="og:url" content={`https://plugma.dev${$page.url.pathname}`} />
<meta property="og:type" content="website" />
</svelte:head>

<div>
Expand Down
5 changes: 2 additions & 3 deletions packages/website/src/routes/docs/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import MarkdownRenderer3 from '@/components/MarkdownRenderer3.svelte';
import Heading from '@/components/Heading.svelte';
import { onMount } from 'svelte';
import Meta from '@/components/Meta.svelte';
export let data;
// function replaceSyntax(data) {
Expand All @@ -24,9 +25,7 @@

<svelte:head>
<title>{data.title}</title>
<meta property="og:title" content={data.title} />
<meta property="og:url" content={`https://plugma.dev${$page.url.pathname}`} />
<meta property="og:type" content="article" />
<Meta title={data.title} url={`https://plugma.dev${$page.url.pathname}`} type="article" />
</svelte:head>

<div>
Expand Down
12 changes: 8 additions & 4 deletions packages/website/src/routes/whats-new/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Badge from '@/components/Badge.svelte';
import Code from '@/components/Code.svelte';
import Icon from '@/components/Icon.svelte';
import Meta from '@/components/Meta.svelte';
export let data;
// function replaceSyntax(data) {
Expand All @@ -15,10 +16,13 @@
</script>

<svelte:head>
<title>Plugma — What's new</title>
<meta property="og:title" content="What's new" />
<meta property="og:url" content={`https://plugma.dev${$page.url.pathname}`} />
<meta property="og:type" content="article" />
<title>Plugma: What's new</title>
<Meta
title="Plugma: What's new"
description="Excelerate your plugin develop with an all in one solution for developing and bundling Figma plugins."
url={`https://plugma.dev${$page.url.pathname}`}
type="article"
/>
</svelte:head>

<div class="my-8 mx-4">
Expand Down

0 comments on commit 1e0834a

Please sign in to comment.