-
Notifications
You must be signed in to change notification settings - Fork 1
/
contentlayer.config.ts
65 lines (58 loc) · 2.2 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
/* v8 ignore start */
// Stryker disable all
import type { Element as hASTElement } from 'hast';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeExternalLinks from 'rehype-external-links';
import { makeSource } from 'contentlayer/source-files';
import rehypePrettyCode from 'rehype-pretty-code';
import rehypeSlug from 'rehype-slug';
import remarkGfm from 'remark-gfm';
import { LANDING_PAGES_FOLDER, BLOG_POSTS_FOLDER, PAGES_FOLDER } from './interop/config/contentlayer/contentlayerConfigTweakers';
import landingPagesDocumentType from './interop/config/contentlayer/landing-pages/documentType';
import CodeSnippetTheme from './interop/config/contentlayer/blog/code-snippet-theme.json';
import blogDocumentTypes from './interop/config/contentlayer/blog/documentTypes';
import pagesDocumentType from './interop/config/contentlayer/pages/documentType';
import validateContentlayerConfig from './interop/validators/contentlayer';
import addClassname from './interop/lib/misc/addClassname';
const contentDirPath = './content';
const contentDirInclude = [BLOG_POSTS_FOLDER, LANDING_PAGES_FOLDER, PAGES_FOLDER];
const documentTypes = [...blogDocumentTypes, landingPagesDocumentType, pagesDocumentType];
validateContentlayerConfig(documentTypes);
export default makeSource({
mdx: {
rehypePlugins: [
rehypeSlug,
[rehypeExternalLinks, { rel: ['nofollow'] }],
[
// @ts-expect-error
rehypePrettyCode,
{
onVisitLine(node: hASTElement) {
// eslint-disable-next-line no-magic-numbers
if (node.children.length === 0) node.children = [{ type: 'text', value: ' ' }];
},
onVisitHighlightedLine(node: hASTElement) {
addClassname(node, 'line--highlighted');
},
onVisitHighlightedWord(node: hASTElement) {
addClassname(node, 'word--highlighted');
},
theme: CodeSnippetTheme
}
],
[
rehypeAutolinkHeadings,
{
behavior: 'wrap'
}
]
],
remarkPlugins: [remarkGfm]
},
disableImportAliasWarning: true,
contentDirInclude,
contentDirPath,
documentTypes
});
// Stryker restore all
/* v8 ignore stop */