Added meta to layouts
This commit is contained in:
18
src/lib/site/meta.ts
Normal file
18
src/lib/site/meta.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { Article, Page, Routed } from './types'
|
||||
|
||||
export type Meta = {
|
||||
title: string
|
||||
description?: string
|
||||
image?: string
|
||||
noindex: boolean
|
||||
}
|
||||
|
||||
const cover = (node: Routed) =>
|
||||
node.collection === 'articles' ? (node as Article).summary.cover.image : null
|
||||
|
||||
export const metaOf = (node: Article | Page): Meta => ({
|
||||
title: node.title,
|
||||
description: node.summary.excerpt || undefined,
|
||||
image: cover(node) ?? undefined,
|
||||
noindex: node.noindex,
|
||||
})
|
||||
Reference in New Issue
Block a user