Skip to content

Commit fb85272

Browse files
committed
feat: better seo data for articles
1 parent f665f77 commit fb85272

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/pages/blog/just-do-something-literally-anything.vue

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ seo({
66
imageType: 'image/jpeg',
77
imageWidth: 800,
88
imageHeight: 511,
9+
type: 'article',
10+
published: '2024-01-21',
911
});
1012
1113
// https://search.google.com/test/rich-results

src/public/sitemap.xml

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
<url>
44
<loc>https://jdw.me/</loc>
55
</url>
6+
<url>
7+
<loc>https://jdw.me/blog</loc>
8+
</url>
9+
<url>
10+
<loc>https://jdw.me/blog/just-do-something-literally-anything</loc>
11+
</url>
612
<url>
713
<loc>https://jdw.me/resume</loc>
814
</url>

src/utils/seo.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export default ({
66
imageType = 'image/png',
77
imageWidth = 600,
88
imageHeight = 600,
9+
author = 'Jonathan Walters',
10+
published,
911
type = 'website',
1012
} = {}) => {
1113
const route = useRoute();
@@ -22,7 +24,7 @@ export default ({
2224
],
2325
});
2426

25-
useSeoMeta({
27+
const seoMeta = {
2628
title: pageTitle ?? title,
2729
colorScheme: 'only light',
2830
themeColor: '#60a5fa',
@@ -40,5 +42,14 @@ export default ({
4042
twitterTitle: title,
4143
twitterSite: '@chalksy',
4244
twitterImage: imageUrl,
43-
});
45+
};
46+
47+
if (type === 'article') {
48+
seoMeta.articleAuthor = author;
49+
if (published) {
50+
seoMeta.articlePublishedTime = published;
51+
}
52+
}
53+
54+
useSeoMeta(seoMeta);
4455
};

0 commit comments

Comments
 (0)