Skip to content

Commit

Permalink
add social preview image and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
candrewlee14 committed Mar 7, 2024
1 parent f38951e commit d883e10
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type Post = {
categories: Categories[]
published: boolean
readTime: number
socialPreview?: string
}

export type WorkEntry = {
Expand Down
1 change: 1 addition & 0 deletions src/posts/2024-03-07_apple-vision-pro.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ categories:
- XR
- Apple
published: true
socialPreview: /apple-vision-pro/apple-vision-pro.webp
---

![Apple Vision Pro](/apple-vision-pro/apple-vision-pro.webp)
Expand Down
4 changes: 4 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
export let data;
</script>

<svelte:head>
<meta property="og:url" content={`https://candrewlee14.github.io${data.pathname}`} />
</svelte:head>

<div class="flex flex-row min-w-screen h-2">
{#each ['bg-red-400 dark:bg-red-600', 'bg-yellow-400 dark:bg-yellow-600', 'bg-green-400 dark:bg-green-600', 'bg-violet-400 dark:bg-violet-600'] as color}
<div class={`flex-grow ${color}`}>&nbsp;</div>
Expand Down
11 changes: 9 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
</script>

<svelte:head>
<title>About Me - Andrew Lee</title>
<meta
name="description"
content="Hello, I'm Andrew Lee! I'm a software developer and student at the University of Utah. Learn more about me!"
content="Hello, I'm Andrew Lee! Learn more about me here."
/>
<title>About Me - Andrew Lee</title>
<meta property="og:title" content="About Me - Andrew Lee" />
<meta property="og:description" content="Hello, I'm Andrew Lee! Learn more about me here." />
<meta property="og:image" content="https://candrewlee14.github.io/candrewlee14-social-preview.png" />
<meta property="og:type" content="profile" />
<meta property="og:profile:first_name" content="Andrew" />
<meta property="og:profile:last_name" content="Lee" />
<meta property="og:profile:username" content="candrewlee14" />
</svelte:head>

<div>
Expand Down
8 changes: 6 additions & 2 deletions src/routes/blog/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone'; // dependent on utc plugin
import { andrewTz } from '$lib/posts';
dayjs.extend(utc);
dayjs.extend(timezone);
Expand All @@ -15,8 +15,12 @@
<title>Blog - Andrew Lee</title>
<meta
name="description"
content="Hello, I'm Andrew Lee! I'm a software developer and student at the University of Utah. Check out my blog!"
content="Hello, I'm Andrew Lee! Check out my blog!"
/>
<meta property="og:title" content="Blog - Andrew Lee" />
<meta property="og:description" content="Hello, I'm Andrew Lee! Check out my blog!" />
<meta property="og:image" content="https://candrewlee14.github.io/candrewlee14-social-preview.png" />
<meta property="og:type" content="website" />
</svelte:head>

<div class="w-full h-full flex justify-center pb-6">
Expand Down
13 changes: 10 additions & 3 deletions src/routes/blog/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone'; // dependent on utc plugin
import { andrewTz } from '$lib/posts';
dayjs.extend(utc);
dayjs.extend(timezone);
const andrewTz = 'America/Denver';
export let data;
</script>

<svelte:head>
<title>{data.meta.title} - Andrew Lee</title>
<meta name="description" content={data.meta.description} />
<meta property="og:title" content={data.meta.title} />
<meta property="og:description" content={`${data.meta.description} - Written by Andrew Lee`}/>
<meta
property="og:image"
content={data.meta.socialPreview
? `https://candrewlee14.github.io${data.meta.socialPreview}`
: 'https://candrewlee14.github.io/candrewlee14-social-preview.png'}
/>
<meta property="og:type" content="website" />
</svelte:head>

<div class="flex flex-col items-center">
Expand Down
11 changes: 9 additions & 2 deletions src/routes/work/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,18 @@
</script>

<svelte:head>
<title>Work - Andrew Lee</title>
<meta
name="description"
content="Hello, I'm Andrew Lee! I'm a software developer and student at the University of Utah. View my work experience here."
content="Hello, I'm Andrew Lee! View my work experience here."
/>
<title>Work - Andrew Lee</title>
<meta property="og:title" content="Work - Andrew Lee" />
<meta
property="og:description"
content="Hello, I'm Andrew Lee! View my work experience here."
/>
<meta name="og:image" content="https://candrewlee14.github.io/candrewlee14-social-preview.png" />
<meta property="og:type" content="website" />
</svelte:head>

<div class="flex flex-col items-center -ml-2">
Expand Down
Binary file added static/candrewlee14-social-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d883e10

Please sign in to comment.