-
-
Notifications
You must be signed in to change notification settings - Fork 157
/
markdoc.config.ts
70 lines (65 loc) · 2.1 KB
/
markdoc.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
import { type AstroMarkdocConfig, defineMarkdocConfig, Markdoc, nodes } from '@astrojs/markdoc/config';
import shiki from '@astrojs/markdoc/shiki';
import { building, contentBlocks as buildingContentBlocks } from './src/markdoc/buildings';
import { item, item_combined_infobox, item_infobox } from './src/markdoc/items';
import { research_link, research_list, research_trees } from './src/markdoc/research';
import type { Tag } from './src/markdoc/types';
import { citizen_name_pack_list, content_block, image_row, meta, social_link } from './src/markdoc/util';
import { version } from './src/markdoc/version';
import { worker, workers_table } from './src/markdoc/workers';
function extendNodeClasses(...extraClasses: string[]): Tag['transform'] {
const result: Tag['transform'] = (node, config) => {
const attributes = node.transformAttributes(config);
const children = node.transformChildren(config);
const classes = attributes['class'] !== undefined ? [attributes['class'].split(' ')] : [];
classes.push(...extraClasses);
attributes['class'] = classes.join(' ');
return new Markdoc.Tag(node.type, attributes, children);
};
return result;
}
export const config: AstroMarkdocConfig = {
tags: {
building,
worker,
workers_table,
item,
item_infobox,
item_combined_infobox,
research_trees,
research_list,
research_link,
version,
social_link,
citizen_name_pack_list,
content_block,
image_row,
meta
},
nodes: {
document: {
...nodes.document,
render: undefined
},
table: {
...nodes.table,
transform: extendNodeClasses('table', 'table-hover', 'table-fit')
},
blockquote: {
...nodes.blockquote,
transform: extendNodeClasses('blockquote-border')
}
},
extends: [
shiki({
theme: 'css-variables',
wrap: true
})
]
};
for (const [name, buildingContentBlockTag] of Object.entries(buildingContentBlocks)) {
if (config.tags) {
config.tags[`building_gui_content_block_${name.toLocaleLowerCase()}`] = buildingContentBlockTag;
}
}
export default defineMarkdocConfig(config);