hide pro themes for alpha

This commit is contained in:
Cory LaViska
2024-12-09 14:31:31 -05:00
parent 76c74fc8a9
commit 5d74d8163b
6 changed files with 46 additions and 17 deletions

View File

@@ -0,0 +1,23 @@
import { parse } from 'node-html-parser';
/**
* Eleventy plugin to add remove elements with <div data-alpha="remove"> from the alpha build.
*/
export function removeDataAlphaElements(options = {}) {
options = {
isAlpha: false,
...options
};
return function (eleventyConfig) {
eleventyConfig.addTransform('remove-data-alpha-elements', content => {
const doc = parse(content, { blockTextElements: { code: true } });
if (options.isAlpha) {
doc.querySelectorAll('[data-alpha="remove"]').forEach(el => el.remove());
}
return doc.toString();
});
};
}