Skip to content

Commit df7765b

Browse files
committed
feat: enabled support for seo
1 parent 3de5e6b commit df7765b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { remarkReadingTime } from './src/lib/remark.mjs';
77

88
// https://astro.build/config
99
export default defineConfig({
10+
site: 'https://getcvfolio.com',
1011
markdown: {
1112
remarkPlugins: [remarkReadingTime],
1213
shikiConfig: {

src/content.config.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1-
import { defineCollection } from 'astro:content';
1+
import { defineCollection, type ImageFunction } from 'astro:content';
22
import { glob } from 'astro/loaders';
33
import { z } from 'zod';
44

5+
export const seoSchemaWithoutImage = z.object({
6+
title: z.string(),
7+
description: z.string(),
8+
type: z.string().optional(),
9+
keywords: z.string().optional(),
10+
canonicalUrl: z.string().optional(),
11+
twitter: z.object({
12+
creator: z.string().optional(),
13+
}).optional()
14+
})
15+
16+
const seoSchema = (image: ImageFunction) =>
17+
z.object({
18+
image: image().optional(),
19+
}).merge(seoSchemaWithoutImage);
20+
521
const pageCollection = defineCollection({
622
loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/pages' }),
7-
schema: z.object({
23+
schema: ({ image }) => z.object({
824
title: z.string(),
25+
seo: seoSchema(image),
926
}),
1027
});
1128

@@ -47,6 +64,7 @@ const postCollection = defineCollection({
4764
title: z.string(),
4865
date: z.date(),
4966
image: image(),
67+
seo: seoSchema(image),
5068
}),
5169
});
5270

0 commit comments

Comments
 (0)