Skip to content

Commit

Permalink
updated site builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Jun 28, 2024
1 parent e607ea1 commit 2c07d72
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
9 changes: 5 additions & 4 deletions webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ export default function (env, argv) {
}
}),
...(argv.mode === 'production' ? [new PurgeCSSPlugin({
paths: () => fs.readdirSync(path.resolve('src'), {recursive: true})
.map((name) => path.join('src', name))
.filter((p) => fs.statSync(p).isFile()),
paths: () => ['src', 'webpack']
.flatMap(p => fs.readdirSync(path.resolve(p), {withFileTypes: true, recursive: true}))
.filter(ent => ent.isFile())
.map(ent => path.resolve(ent.path, ent.name)),
safelist: {
standard: [/^table($|\W)/, /^(?:bs-)?(offcanvas|popover|tooltip|blockquote)(?:$|\W)/, 'fade', 'show'],
standard: [/^(?:bs-)?(offcanvas|popover|tooltip)(?:$|\W)/, 'fade', 'show'],
}
})] : []),
],
Expand Down
21 changes: 21 additions & 0 deletions webpack/markdown-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ function blockQuoteStyle() {
};
}

function wrapTable() {
return (tree) => {
visit(tree, /** @param node {Element} */node => node.tagName === 'table',
/**
* @param node {Element}
* @param index {number}
* @param parent {Element}
*/
(node, index, parent) => {
node.properties.className = 'table';
parent.children[index] = {
type: 'element',
tagName: 'div',
properties: {className: 'table-responsive'},
children: [node]
};
});
};

}

function alertRestyle() {
return (tree) => {
Expand Down Expand Up @@ -106,6 +126,7 @@ const parser = remark()
.use(autoLead)
.use(headingHr)
.use(blockQuoteStyle)
.use(wrapTable)
.use(extractMeta)
.use(rehypeStringify, {allowDangerousCharacters: true, allowDangerousHtml: true});

Expand Down

0 comments on commit 2c07d72

Please sign in to comment.