Skip to content

Commit

Permalink
Add some open graph tags
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Aug 27, 2023
1 parent 4974b65 commit 80d006c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"preview": "astro preview",
"astro": "astro",
"check": "astro check",
"deploy": "tsx ./scripts/deploy.ts"
"deploy": "tsx ./scripts/deploy.ts",
"sync": "astro sync"
},
"dependencies": {
"@astrojs/markdoc": "^0.4.4",
Expand Down
1 change: 1 addition & 0 deletions site/src/content/blog/test.mdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Test
description: "Test post"
---

I'm a test post
1 change: 1 addition & 0 deletions site/src/content/blog/typography-test.mdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: I'm a Heading 1
description: Typography test
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Expand Down
2 changes: 1 addition & 1 deletion site/src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'astro/zod';

const blogCollection = defineCollection({
type: 'content',
schema: z.object({ title: z.string() }),
schema: z.object({ title: z.string(), description: z.string() }),
});
export const collections = {
blog: blogCollection,
Expand Down
7 changes: 6 additions & 1 deletion site/src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ import { base, header, nav } from './Base.css';
interface Props {
title: string;
description: string;
type: 'website' | 'article';
}
const { title } = Astro.props;
const { title, description, type } = Astro.props;
---

<html class={base} lang='en'>
<head>
<meta charset='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1' />
<meta property="og:title" content={title} />
<meta property="og:description" content={description}/>
<meta property="og:type" content={type} />
<title>{title}</title>
<link rel='preconnect' href='https://fonts.googleapis.com' />
<link rel='preconnect' href='https://fonts.gstatic.com' crossorigin />
Expand Down
5 changes: 3 additions & 2 deletions site/src/layouts/BlogPost.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import Base from './Base.astro';
interface Props {
title: string;
description: string;
slug: string;
}
const { title, slug } = Astro.props;
const { title, description, slug } = Astro.props;
---

<Base title={title}>
<Base title={title} description={description} type='article'>
<main>
<h1 id={slug}>{title}</h1>
<article>
Expand Down
6 changes: 5 additions & 1 deletion site/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const blogEntries = (await getCollection('blog')).map((entry) => ({
}));
---

<Base title='Adam Skoufis - Blog'>
<Base
title='Adam Skoufis - Blog'
description='My personal website'
type='website'
>
<h1 id='blog'>Blog</h1>
{
blogEntries.map((entry) => (
Expand Down
6 changes: 5 additions & 1 deletion site/src/pages/posts/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const { entry } = Astro.props;
const { Content } = await entry.render();
---

<BlogPost title={entry.data.title} slug={entry.slug}>
<BlogPost
title={entry.data.title}
slug={entry.slug}
description={entry.data.description}
>
<Content />
</BlogPost>

0 comments on commit 80d006c

Please sign in to comment.