-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontentlayer.config.ts
86 lines (81 loc) · 2.4 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
import remarkCallouts from "@portaljs/remark-callouts"
import { makeSource } from "contentlayer/source-files"
import { rehypeAccessibleEmojis } from "rehype-accessible-emojis"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
import rehypeKatex from "rehype-katex"
import rehypePrettyCode from "rehype-pretty-code"
import rehypeSlug from "rehype-slug"
import remarkGfm from "remark-gfm"
import remarkMath from "remark-math"
import remarkSmartypants from "remark-smartypants"
import remarkUnwrapImages from "remark-unwrap-images"
import wikiLinkPlugin from "remark-wiki-link"
import { LifeLog } from "./content/definitions/lifelog"
import { Note } from "./content/definitions/note"
import rehypeImageMetadata from "./utils/plugins/image-metadata"
const pageResolver = (name: string) => [
name.replace(/-/g, "").replace(/ /g, "-").toLowerCase(),
]
const hrefTemplate = (permalink: string) => `/notes/${permalink}`
const rehypePrettyCodeOptions = {
theme: {
dark: "github-dark-dimmed",
light: "github-light",
},
defaultLang: {
block: "plaintext",
inline: "plaintext",
},
// Callbacks to customize the output of the nodes
onVisitLine(node) {
// Prevent lines from collapsing in `display: grid` mode, and
// allow empty lines to be copy/pasted
if (node.children.length === 0) {
node.children = [{ type: "text", value: " " }]
}
node.properties.className = [""]
},
onVisitHighlightedLine(node) {
// Adding a class to the highlighted line
node.properties.className.push("highlighted")
},
}
export default makeSource({
contentDirPath: "content",
documentTypes: [Note, LifeLog],
date: { timezone: "Asia/Kolkata" },
mdx: {
remarkPlugins: [
[remarkGfm],
[remarkMath],
[remarkUnwrapImages],
[remarkCallouts],
[
wikiLinkPlugin,
{
pageResolver,
hrefTemplate,
aliasDivider: "|",
newClassName: "text-secondary",
},
],
[remarkSmartypants, { quotes: false, dashes: "oldschool" }],
],
rehypePlugins: [
[rehypeKatex, { output: "mathml" }],
[rehypeSlug],
[rehypeImageMetadata],
[rehypeAccessibleEmojis],
[rehypePrettyCode, rehypePrettyCodeOptions],
[
rehypeAutolinkHeadings,
{
behaviour: "wrap",
properties: {
className: ["anchor"],
},
},
],
],
},
})