Skip to content

Commit

Permalink
og metadata + post sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mordechai Dror committed Sep 24, 2023
1 parent 950fe26 commit d4e5f67
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@ import Footer from "../components/Footer.astro";
interface Props {
title?: string;
image?: string;
}
let title = `vorant94`;
if(Astro.props.title) {
title += ` | ${Astro.props.title}`;
}
const {title, image} = Astro.props;
const pageTitle = title ? `vorant94 | ${title}` : `vorant94's Blog`;
const ogTitle = title ?? `A personal space of yet another full-stack dev`
const ogType = title ? 'article' : 'website'
const ogUrl = new URL(Astro.url.pathname, Astro.site);
const ogImage = new URL(image ?? '/favicon.ico', Astro.site);
---

<!doctype html>
<html lang="en">
<html lang="en" prefix="og: https://ogp.me/ns#">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content={ogTitle} />
<meta property="og:type" content={ogType} />
<meta property="og:url" content={ogUrl} />
<meta property="og:image" content={ogImage} />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<title>{title}</title>
<title>{pageTitle}</title>
</head>
<body class="flex flex-col min-h-screen mx-auto md:max-w-md lg:max-w-lg xl:max-w-xl 2xl:max-w-2xl">

Expand Down
4 changes: 3 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import { getCollection } from 'astro:content';
import Layout from '../layouts/Layout.astro';
const posts = await getCollection('posts');
const posts = (await getCollection('posts')).sort((a,b) => {
return new Date(b.data.publishedAt) - new Date(a.data.publishedAt);
});
---

Expand Down
9 changes: 9 additions & 0 deletions src/pages/posts/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ const { Content } = await post.render();
<article class="prose">
<Content />
</article>

<!--<script src="https://utteranc.es/client.js"-->
<!-- repo="vorant94/vorant94.github.io"-->
<!-- issue-term="og:title"-->
<!-- label="comment"-->
<!-- theme="github-light"-->
<!-- crossorigin="anonymous"-->
<!-- async>-->
<!--</script>-->
</Layout>

0 comments on commit d4e5f67

Please sign in to comment.