forked from solfate/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentlayer.config.ts
102 lines (98 loc) · 2.6 KB
/
contentlayer.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { podcastEpisodeImage } from "./src/lib/podcast";
import { createStandardSlug } from "./src/lib/helpers";
import { defineDocumentType, makeSource } from "contentlayer/source-files";
/**
* Podcast episode schema
*/
export const PodcastEpisode = defineDocumentType(() => ({
name: "PodcastEpisode",
filePathPattern: `podcast/episodes/**/*.md`,
fields: {
title: {
type: "string",
description: "The title of the episode",
required: true,
},
longTitle: {
type: "string",
description: "The longer title of the episode",
required: false,
},
date: {
type: "date",
description: "The public date of the episode",
required: false,
},
draft: {
type: "boolean",
description: "Draft status of the episode",
required: false,
},
featured: {
type: "boolean",
description: "Whether or not this episode is featured",
required: false,
},
description: {
type: "string",
description:
"Brief description of the episode (also used in the SEO metadata)",
required: true,
},
tags: {
type: "string",
// type: "list",
// of: { type: "string" },
description: "Comma separated listing of tags",
required: false,
},
image: {
type: "string",
description: "Social share image",
},
transistorUrl: {
type: "string",
description:
"Brief description of the episode (also used in the SEO metadata)",
required: false,
},
duration: {
type: "string",
description: "Duration of the episode",
required: false,
},
},
computedFields: {
ep: {
description: "Episode number (aka the file name)",
type: "string",
resolve: (record) => createStandardSlug(record._id),
},
draft: {
description: "Draft status of the episode",
type: "boolean",
resolve: (record) =>
record?.draft ?? record._raw.sourceFileName.startsWith("_"),
},
slug: {
description: "Computed slug of the episode",
type: "string",
resolve: (record) => record?.slug ?? createStandardSlug(record._id),
},
href: {
description: "Local url path of the episode",
type: "string",
resolve: (record) =>
`/podcast/${record?.slug ?? createStandardSlug(record._id)}`,
},
image: {
description: "Primary image for the podcast episode",
type: "string",
resolve: (record) => podcastEpisodeImage(record.image),
},
},
}));
export default makeSource({
contentDirPath: "content",
documentTypes: [PodcastEpisode],
});