forked from NorfolkDev/norfolkdevelopers-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentlayer.config.js
147 lines (144 loc) · 3.45 KB
/
contentlayer.config.js
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import rehypePrism from "@mapbox/rehype-prism";
import remarkGfm from 'remark-gfm'
import { defineDocumentType, makeSource } from "contentlayer/source-files";
import removeMarkdown from "remove-markdown";
import siteConfig from "./site.config";
export const Post = defineDocumentType(() => ({
name: "Post",
contentType: "mdx",
filePathPattern: `posts/**/*.mdx`,
fields: {
title: {
type: "string",
description: "The title of the post",
required: true,
},
date: {
type: "date",
description: "The date of the post",
required: true,
},
author: {
type: "string",
description: "The author of the post",
required: true,
},
tags: {
type: "string",
},
hero: {
type: "string",
},
layout: {
type: "string",
},
canonical: {
type: "string",
},
sponsored: {
type: "boolean",
},
},
computedFields: {
url: {
type: "string",
resolve: (post) => `/${post._raw.flattenedPath}`,
},
editUrl: {
type: "string",
resolve: (post) =>
`${siteConfig.githubUrl}edit/master/content/${post._raw.sourceFilePath}`,
},
slug: {
type: "string",
// @TODO: Investigate removing the call to the replace method, is there a better contentlayer prop?
resolve: (post) => post._raw.flattenedPath.replace("posts/", ""),
},
// @TODO: Support these natively in the markdown posts (with actual yaml lists)
authors: {
type: "array",
resolve: (post) => post.author.split(", "),
},
tagList: {
type: "array",
resolve: (post) => post.tags.split(", "),
},
excerpt: {
type: "string",
resolve: (post) => removeMarkdown(post.body.raw).slice(0, 280) + "...",
},
},
}));
export const Job = defineDocumentType(() => ({
name: "Job",
contentType: "mdx",
filePathPattern: "jobs/**/*.mdx",
fields: {
title: {
type: "string",
description: "The title of the job",
required: true,
},
date: {
type: "date",
description: "The date the job was posted",
required: true,
},
expiryDate: {
type: "date",
description: "The date the job was posted",
required: true,
},
role: {
type: "string",
description: "The job role",
required: true,
},
salary: {
type: "string",
description: "The job salary",
required: true,
},
company: {
type: "string",
description: "The company that's recruiting for this role",
required: true,
},
location: {
type: "string",
description:
"The location required for this role (Remote is a valid option)",
required: true,
},
seniority: {
type: "string",
description: "What seniority is this position (e.g. Senior, Junior etc)",
required: true,
},
apply: {
type: "string",
description:
"How should applicants apply (Used as a link, mailto is a valid option)",
required: true,
},
layout: {
type: "string",
description:
"How should applicants apply (Used as a link, mailto is a valid option)",
},
},
computedFields: {
url: {
type: "string",
resolve: (post) => `/jobs/${post._raw.flattenedPath}`,
},
},
}));
export default makeSource({
contentDirPath: "content",
documentTypes: [Post, Job],
mdx: {
rehypePlugins: [rehypePrism],
remarkPlugins: [remarkGfm],
},
});