-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcontent.config.ts
81 lines (72 loc) · 2.21 KB
/
content.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
import { type CollectionSource, type DefinedCollection, defineCollection, defineContentConfig, z } from '@nuxt/content';
import { asRobotsCollection } from '@nuxtjs/robots/content';
import { asSitemapCollection } from '@nuxtjs/sitemap/content';
const DOCUMENTS = 'content/documents/*.md';
const JOBS = 'content/jobs/*.md';
const TESTIMONIALS = 'content/testimonials/*.md';
function getSource(path: string, dataOrigin: 'remote' | 'local'): CollectionSource {
if (dataOrigin === 'remote') {
return {
include: path,
prefix: path.split('/')[1],
repository: 'https://github.com/rotki/rotki.com',
};
}
else {
return {
cwd: '~~/',
include: path,
prefix: path.split('/')[1],
};
}
}
const documentSchema = z.object({
address: z.string().optional(),
description: z.string(),
subtitle: z.string().optional(),
title: z.string(),
});
const jobSchema = z.object({
category: z.string(),
description: z.string(),
open: z.boolean(),
tags: z.array(z.string()),
title: z.string(),
});
const testimonialSchema = z.object({
avatar: z.string().optional(),
url: z.string().optional(),
username: z.string(),
visible: z.boolean(),
});
function getDocumentsCollection(dataOrigin: 'remote' | 'local'): DefinedCollection {
return defineCollection({
schema: documentSchema,
source: getSource(DOCUMENTS, dataOrigin),
type: 'page',
});
}
function getJobsCollection(dataOrigin: 'remote' | 'local'): DefinedCollection {
return defineCollection(asSitemapCollection({
schema: jobSchema,
source: getSource(JOBS, dataOrigin),
type: 'page',
}));
}
function getTestimonialsCollection(dataOrigin: 'remote' | 'local'): DefinedCollection {
return defineCollection(asRobotsCollection({
schema: testimonialSchema,
source: getSource(TESTIMONIALS, dataOrigin),
type: 'page',
}));
}
export default defineContentConfig({
collections: {
documentsLocal: getDocumentsCollection('local'),
documentsRemote: getDocumentsCollection('remote'),
jobsLocal: getJobsCollection('local'),
jobsRemote: getJobsCollection('remote'),
testimonialsLocal: getTestimonialsCollection('local'),
testimonialsRemote: getTestimonialsCollection('remote'),
},
});