mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 02:59:13 +00:00
chore(docs) - reduce build time
This commit is contained in:
@@ -9,11 +9,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Document} content
|
* @param {String} rawContent
|
||||||
* @param {Replacements} replacements
|
* @param {Replacements} replacements
|
||||||
*/
|
*/
|
||||||
module.exports = function (content, replacements) {
|
module.exports = function (rawContent, replacements) {
|
||||||
|
let content = rawContent;
|
||||||
replacements.forEach(replacement => {
|
replacements.forEach(replacement => {
|
||||||
content.body.innerHTML = content.body.innerHTML.replaceAll(replacement.pattern, replacement.replacement);
|
content = content.replaceAll(replacement.pattern, replacement.replacement);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return content;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,7 +115,13 @@ module.exports = function (eleventyConfig) {
|
|||||||
//
|
//
|
||||||
// Transforms
|
// Transforms
|
||||||
//
|
//
|
||||||
eleventyConfig.addTransform('html-transform', function (content) {
|
eleventyConfig.addTransform('html-transform', function (rawContent) {
|
||||||
|
let content = replacer(rawContent, [
|
||||||
|
{ pattern: '%VERSION%', replacement: customElementsManifest.package.version },
|
||||||
|
{ pattern: '%CDNDIR%', replacement: cdndir },
|
||||||
|
{ pattern: '%NPMDIR%', replacement: npmdir }
|
||||||
|
]);
|
||||||
|
|
||||||
// Parse the template and get a Document object
|
// Parse the template and get a Document object
|
||||||
const doc = new JSDOM(content, {
|
const doc = new JSDOM(content, {
|
||||||
// We must set a default URL so links are parsed with a hostname. Let's use a bogus TLD so we can easily
|
// We must set a default URL so links are parsed with a hostname. Let's use a bogus TLD so we can easily
|
||||||
@@ -140,11 +146,6 @@ module.exports = function (eleventyConfig) {
|
|||||||
scrollingTables(doc);
|
scrollingTables(doc);
|
||||||
copyCodeButtons(doc); // must be after codePreviews + highlightCodeBlocks
|
copyCodeButtons(doc); // must be after codePreviews + highlightCodeBlocks
|
||||||
typography(doc, '#content');
|
typography(doc, '#content');
|
||||||
replacer(doc, [
|
|
||||||
{ pattern: '%VERSION%', replacement: customElementsManifest.package.version },
|
|
||||||
{ pattern: '%CDNDIR%', replacement: cdndir },
|
|
||||||
{ pattern: '%NPMDIR%', replacement: npmdir }
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Serialize the Document object to an HTML string and prepend the doctype
|
// Serialize the Document object to an HTML string and prepend the doctype
|
||||||
content = `<!DOCTYPE html>\n${doc.documentElement.outerHTML}`;
|
content = `<!DOCTYPE html>\n${doc.documentElement.outerHTML}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user