feat: User setup (#95)

* allow users to add plugins to setup markdown and eleventy

* comments on function

* added userSetup.js to plugin-info.json
This commit is contained in:
Utsob Roy 2023-03-06 13:37:17 +06:00 committed by GitHub
parent 1670b2e64b
commit 59c3cde9e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -7,6 +7,10 @@ const tocPlugin = require("eleventy-plugin-nesting-toc");
const { parse } = require("node-html-parser");
const { headerToId, namedHeadingsFilter } = require("./src/helpers/utils");
const {
userMarkdownSetup,
userEleventySetup,
} = require("./src/helpers/userSetup");
const tagRegex = /(^|\s|\>)(#[^\s!@#$%^&*()=+\.,\[{\]};:'"?><]+)(?!([^<]*>))/g;
@ -156,7 +160,8 @@ module.exports = function (eleventyConfig) {
return prefix + n;
};
});
})
.use(userMarkdownSetup);
eleventyConfig.setLibrary("md", markdownLib);
@ -320,6 +325,8 @@ module.exports = function (eleventyConfig) {
return variable;
});
userEleventySetup(eleventyConfig);
return {
dir: {
input: "src/site",

View File

@ -12,7 +12,8 @@
"src/site/img/tree-1.svg",
"src/site/img/tree-2.svg",
"src/site/img/tree-3.svg",
"src/helpers/userUtils.js"
"src/helpers/userUtils.js",
"src/helpers/userSetup.js"
],
"filesToModify": [
".eleventy.js",

10
src/helpers/userSetup.js Normal file
View File

@ -0,0 +1,10 @@
function userMarkdownSetup(md) {
// The md parameter stands for the markdown-it instance used throughout the site generator.
// Feel free to add any plugin you want here instead of /.eleventy.js
}
function userEleventySetup(eleventyConfig) {
// The eleventyConfig parameter stands for the the config instantiated in /.eleventy.js.
// Feel free to add any plugin you want here instead of /.eleventy.js
}
exports.userMarkdownSetup = userMarkdownSetup;
exports.userEleventySetup = userEleventySetup;