Convert CommonJS syntax to ESM syntax

This commit is contained in:
Helen Chong 2024-07-19 02:08:10 +08:00
parent aae7b8476a
commit 1dc8fd8959
4 changed files with 30 additions and 21 deletions

View File

@ -1,12 +1,14 @@
// Installed Plugins
const pluginRss = require("@11ty/eleventy-plugin-rss");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const metagen = require('eleventy-plugin-metagen');
const emojiReadTime = require("@11tyrocks/eleventy-plugin-emoji-readtime");
import pluginRss from "@11ty/eleventy-plugin-rss";
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import metagen from 'eleventy-plugin-metagen';
import emojiReadTime from "@11tyrocks/eleventy-plugin-emoji-readtime";
const slugify = require("slugify");
import slugify from "slugify";
module.exports = function (eleventyConfig) {
import markdownPlugin from "./eleventy.config.md.js";
export default function (eleventyConfig) {
// Copy files
eleventyConfig.addPassthroughCopy("./src/assets/");
eleventyConfig.addWatchTarget("./src/assets/");
@ -15,7 +17,7 @@ module.exports = function (eleventyConfig) {
});
// Custom Plugins
eleventyConfig.addPlugin(require('./eleventy.config.md.js'));
eleventyConfig.addPlugin(markdownPlugin);
// Installed Plugins
eleventyConfig.addPlugin(pluginRss);

View File

@ -1,16 +1,22 @@
/* CONFIGURATION FOR MARKDOWN TEMPLATES */
// Installed Plugins
const pluginTOC = require('@uncenter/eleventy-plugin-toc');
const embedEverything = require("eleventy-plugin-embed-everything");
import pluginTOC from '@uncenter/eleventy-plugin-toc';
import embedEverything from "eleventy-plugin-embed-everything";
// Configure slug filter
const slugify = require("slugify");
// Configure markdown-it plugins
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
import slugify from "slugify";
module.exports = function (eleventyConfig) {
// markdown-it plugins
import markdownIt from "markdown-it";
import markdownItAnchor from "markdown-it-anchor";
import markdownItAttribution from "markdown-it-attribution";
import markdownItAttrs from "markdown-it-attrs";
import markdownItBracketedSpans from 'markdown-it-bracketed-spans';
import markdownItDefList from "markdown-it-deflist";
import markdownItFootnote from "markdown-it-footnote";
export default function (eleventyConfig) {
// Installed Plugins
eleventyConfig.addPlugin(pluginTOC, {
tags: ['h2', 'h3', 'h4', 'h5', 'h6'],
@ -73,11 +79,11 @@ module.exports = function (eleventyConfig) {
linkify: true,
})
.use(markdownItAnchor, markdownItAnchorOptions)
.use(require("markdown-it-attribution"))
.use(require("markdown-it-attrs"))
.use(require("markdown-it-bracketed-spans"))
.use(require("markdown-it-deflist"))
.use(require('markdown-it-footnote'));
.use(markdownItAttribution)
.use(markdownItAttrs)
.use(markdownItBracketedSpans)
.use(markdownItDefList)
.use(markdownItFootnote);
// Configure linkify
markdownLibrary.linkify.set({ fuzzyLink: false });

View File

@ -4,6 +4,7 @@
"start": "bunx @11ty/eleventy --serve --quiet",
"build": "bunx @11ty/eleventy"
},
"type": "module",
"devDependencies": {
"@types/bun": "^1.1.6"
},

View File

@ -1,4 +1,4 @@
module.exports = {
export default {
siteName: "Leilukin's Hub",
siteUrl: "https://leilukin.com" || "http://localhost:8080",
siteDomain: "leilukin.com",
@ -8,6 +8,6 @@ module.exports = {
siteAuthor: {
name: "Leilukin",
email: "contact@leilukin.com",
url: this.siteUrl + "/about"
url: "https://leilukin.com/about"
}
}