/
eleventy.config.cjs
187 lines (164 loc) · 6.23 KB
/
eleventy.config.cjs
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// @ts-check
Error.stackTraceLimit = 50;
const SyntaxHighlightPlugin = require('@11ty/eleventy-plugin-syntaxhighlight');
const DirectoryOutputPlugin = require('@11ty/eleventy-plugin-directory-output');
const AnchorsPlugin = require('@patternfly/pfe-tools/11ty/plugins/anchors.cjs');
const CustomElementsManifestPlugin =
require('@patternfly/pfe-tools/11ty/plugins/custom-elements-manifest.cjs');
const CEMShortcodesPlugin = require('./docs/_plugins/cem-shortcodes.cjs');
const OrderTagsPlugin = require('@patternfly/pfe-tools/11ty/plugins/order-tags.cjs');
const TodosPlugin = require('@patternfly/pfe-tools/11ty/plugins/todos.cjs');
const TOCPlugin = require('@patternfly/pfe-tools/11ty/plugins/table-of-contents.cjs');
const SassPlugin = require('eleventy-plugin-dart-sass');
const RHDSPlugin = require('./docs/_plugins/rhds.cjs');
const DesignTokensPlugin = require('./docs/_plugins/tokens.cjs');
const RHDSMarkdownItPlugin = require('./docs/_plugins/markdown-it.cjs');
const ImportMapPlugin = require('./docs/_plugins/importMap.cjs');
const path = require('node:path');
const isWatch =
process.argv.includes('--serve') || process.argv.includes('--watch');
/** @param {import('@11ty/eleventy/src/UserConfig')} eleventyConfig */
module.exports = function(eleventyConfig) {
eleventyConfig.setQuietMode(true);
eleventyConfig.watchIgnores?.add('docs/assets/redhat/');
eleventyConfig.watchIgnores?.add('**/*.spec.ts');
eleventyConfig.watchIgnores?.add('**/*.d.ts');
eleventyConfig.watchIgnores?.add('**/*.js.map');
eleventyConfig.watchIgnores?.add('elements/*/test/');
eleventyConfig.watchIgnores?.add('lib/elements/*/test/');
eleventyConfig.addPassthroughCopy('docs/public/red-hat-outfit.css');
eleventyConfig.addPassthroughCopy('docs/patterns/**/*.{svg,jpg,jpeg,png}');
eleventyConfig.addPassthroughCopy('docs/CNAME');
eleventyConfig.addPassthroughCopy('docs/.nojekyll');
eleventyConfig.addPassthroughCopy('docs/robots.txt');
eleventyConfig.addPassthroughCopy('docs/assets/**/*');
eleventyConfig.on('eleventy.before', function({ runMode }) {
eleventyConfig.addGlobalData('runMode', runMode);
});
eleventyConfig.addPlugin(RHDSMarkdownItPlugin);
eleventyConfig.addPlugin(SassPlugin, {
sassLocation: `${path.join(__dirname, 'docs', 'scss')}/`,
sassIndexFile: 'styles.scss',
includePaths: ['node_modules', '**/*.{scss,sass}'],
domainName: '',
outDir: path.join(__dirname, '_site'),
});
/** Table of Contents Shortcode */
eleventyConfig.addPlugin(TOCPlugin, {
tags: ['h2', 'h3', 'h4', 'h5', 'h6'],
wrapperClass: 'table-of-contents',
headingText: 'Table of Contents',
});
/** Bespoke import map for ux-dot pages and demos */
eleventyConfig.addPassthroughCopy({
'node_modules/@lit/reactive-element': '/assets/packages/@lit/reactive-element',
});
eleventyConfig.addPassthroughCopy({
'elements': 'assets/packages/@rhds/elements/elements/',
});
eleventyConfig.addPassthroughCopy({ 'lib': 'assets/packages/@rhds/elements/lib/' });
eleventyConfig.addPlugin(ImportMapPlugin, {
nodemodulesPublicPath: '/assets/packages',
manualImportMap: {
imports: {
'@rhds/tokens/': '/assets/packages/@rhds/tokens/js/',
'@rhds/elements/': '/assets/packages/@rhds/elements/elements/',
'@rhds/elements/lib/': '/assets/packages/@rhds/elements/lib/',
'@patternfly/elements/': '/assets/packages/@patternfly/elements/',
'@patternfly/icons/': '/assets/packages/@patternfly/icons/',
'@patternfly/pfe-core/': '/assets/packages/@patternfly/pfe-core/',
},
},
localPackages: [
// ux-dot dependencies
'fuse.js',
'element-internals-polyfill',
// RHDS dependencies
// `manualImportMap` is not traced, so we need to manually specify these
//
// 1st party
'@rhds/tokens',
'@rhds/tokens/media.js',
'@rhds/tokens/meta.js',
'@patternfly/elements',
'@patternfly/icons/far/',
'@patternfly/icons/fas/',
'@patternfly/icons/fab/',
'@patternfly/icons/patternfly/',
'@patternfly/pfe-core',
// Vendor
'lit',
'lit/directives/if-defined.js',
'lit-html',
'lit-element',
'@lit/reactive-element',
'@lit/context',
'tslib',
'@floating-ui/dom',
'@floating-ui/core',
],
});
// RHDS Tokens docs
eleventyConfig.addPlugin(DesignTokensPlugin);
eleventyConfig.addPassthroughCopy({
'node_modules/@rhds/tokens/css/global.css': '/assets/rhds.css',
});
eleventyConfig.addPassthroughCopy({
'node_modules/@lit/reactive-element': '/assets/packages/@lit/reactive-element',
});
/** Generate and consume custom elements manifests */
eleventyConfig.addPlugin(CustomElementsManifestPlugin, {
renderTitleInOverview: false,
});
eleventyConfig.addPlugin(CEMShortcodesPlugin);
/** Collections to organize by order instead of date */
eleventyConfig.addPlugin(OrderTagsPlugin, { tags: ['develop'] });
/** list todos */
eleventyConfig.addPlugin(TodosPlugin);
/** fancy syntax highlighting with diff support */
eleventyConfig.addPlugin(SyntaxHighlightPlugin);
/** Add IDs to heading elements */
eleventyConfig.addPlugin(AnchorsPlugin, {
exclude: /\/elements\/.*\/demo\//,
formatter($, existingids) {
if (
!existingids.includes($.attr('id'))
&& $.attr('slot')
&& $.closest('pf-card')
) {
return null;
} else {
return eleventyConfig.getFilter('slug')($.text())
.replace(/[&,+()$~%.'":*?!<>{}]/g, '');
}
},
});
!isWatch && eleventyConfig.addPlugin(DirectoryOutputPlugin, {
// Customize columns
columns: {
filesize: true, // Use `false` to disable
benchmark: true, // Use `false` to disable
},
// Will show in yellow if greater than this number of bytes
warningFileSize: 400 * 1000,
});
/**
* Collections to organize by 'order' value in front matter, then alphabetical by title;
* instead of by date
*/
eleventyConfig.addPlugin(RHDSPlugin, {
tagsToAlphabetize: [
'component',
'foundations',
'getstarted',
],
});
return {
templateFormats: ['html', 'md', 'njk', '11ty.cjs'],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dir: {
input: './docs',
},
};
};