mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-01 05:43:01 +00:00
website: update all 11ty file to .mjs / ESM modules
This commit is contained in:
parent
1f8ad8e106
commit
39bba6bef1
11 changed files with 76 additions and 92 deletions
|
@ -1,13 +1,15 @@
|
|||
"use strict";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
import columnify from "columnify";
|
||||
import htmlentities from "html-entities";
|
||||
|
||||
const columnify = require("columnify");
|
||||
const htmlentities = require("html-entities");
|
||||
import a from "./lib/Ansi.mjs";
|
||||
import parse_sections from "./lib/parse_sections.mjs";
|
||||
|
||||
const a = require("./lib/Ansi.js");
|
||||
const parse_sections = require("./lib/parse_sections.js");
|
||||
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great!
|
||||
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
|
||||
|
||||
let { sections, categories } = parse_sections(fs.readFileSync(
|
||||
path.resolve(
|
||||
|
@ -36,7 +38,7 @@ console.log(columnify(Array.from(categories).map(el => { return {
|
|||
colour: el[1]
|
||||
} })));
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
layout: "theme.njk",
|
||||
title: "Reference",
|
||||
tags: "navigable",
|
|
@ -1,6 +1,11 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const htmlentities = require("html-entities");
|
||||
"use strict";
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import htmlentities from 'html-entities';
|
||||
|
||||
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great!
|
||||
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
|
||||
|
||||
function read_contributors() {
|
||||
return fs.readFileSync(path.resolve(__dirname, "../../CONTRIBUTORS.tsv"), "utf-8")
|
||||
|
@ -20,4 +25,4 @@ const contributors = read_contributors();
|
|||
|
||||
console.log(`CONTRIBUTORS`, contributors);
|
||||
|
||||
module.exports = contributors;
|
||||
export default contributors;
|
|
@ -10,11 +10,9 @@ import phin from "phin";
|
|||
import CleanCSS from "clean-css";
|
||||
import { minify as minify_html } from "html-minifier-terser";
|
||||
|
||||
import UpgradeHelper from "@11ty/eleventy-upgrade-help";
|
||||
|
||||
import moondoc_runner from "./lib/moondoc_runner.js";
|
||||
import HTMLPicture from "./lib/HTMLPicture.js";
|
||||
import FileFetcher from "./lib/FileFetcher.js";
|
||||
import moondoc_runner from "./lib/moondoc_runner.mjs";
|
||||
import HTMLPicture from "./lib/HTMLPicture.mjs";
|
||||
import FileFetcher from "./lib/FileFetcher.mjs";
|
||||
const file_fetcher = new FileFetcher();
|
||||
|
||||
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great!
|
||||
|
@ -129,7 +127,6 @@ export default function config(eleventyConfig) {
|
|||
path.resolve(__dirname, "_site/api/index.html")
|
||||
);
|
||||
|
||||
eleventyConfig.addPlugin(UpgradeHelper);
|
||||
eleventyConfig.addTransform("cssmin", do_minify_css);
|
||||
eleventyConfig.addTransform("htmlmin", do_minify_html);
|
||||
|
||||
|
|
9
.docs/eslint.config.mjs
Normal file
9
.docs/eslint.config.mjs
Normal file
|
@ -0,0 +1,9 @@
|
|||
export default [
|
||||
{
|
||||
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
||||
rules: {
|
||||
"prefer-const": "warn",
|
||||
"no-constant-binary-expression": "error"
|
||||
}
|
||||
}
|
||||
];
|
|
@ -85,4 +85,4 @@ class Ansi {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = new Ansi();
|
||||
export default new Ansi();
|
|
@ -1,12 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
|
||||
const phin = require("phin");
|
||||
import phin from "phin";
|
||||
|
||||
import a from "./Ansi.mjs";
|
||||
|
||||
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great!
|
||||
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
|
||||
|
||||
const a = require("./Ansi.js");
|
||||
var pretty_ms = null;
|
||||
|
||||
class FileFetcher {
|
||||
|
@ -19,7 +23,7 @@ class FileFetcher {
|
|||
}
|
||||
|
||||
fetch_file(url) {
|
||||
let target_client = path.join(`/img`, path.basename(url));
|
||||
const target_client = path.join(`/img`, path.basename(url));
|
||||
|
||||
if(this.#cache.includes(url)) return target_client;
|
||||
|
||||
|
@ -37,11 +41,11 @@ class FileFetcher {
|
|||
|
||||
if(this.#pkg_obj === null) {
|
||||
this.#pkg_obj = JSON.parse(await fs.promises.readFile(
|
||||
path.join(path.dirname(__dirname), "package.json"), "utf8"
|
||||
path.resolve(path.dirname(__dirname), "package.json"), "utf8"
|
||||
));
|
||||
}
|
||||
|
||||
let target_download = path.join(`_site/img`, path.basename(url));
|
||||
const target_download = path.join(`_site/img`, path.basename(url));
|
||||
|
||||
const response = await phin({
|
||||
url,
|
||||
|
@ -64,4 +68,4 @@ class FileFetcher {
|
|||
|
||||
}
|
||||
|
||||
module.exports = FileFetcher;
|
||||
export default FileFetcher;
|
|
@ -1,14 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
const os = require(`os`);
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
import os from 'os';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const debug = require("debug")("image");
|
||||
const imagickal = require("imagickal");
|
||||
const htmlentities = require("html-entities");
|
||||
import imagickal from 'imagickal';
|
||||
import htmlentities from "html-entities";
|
||||
import PQueue from "p-queue";
|
||||
import pMemoize from "p-memoize";
|
||||
import pretty_ms from "pretty-ms";
|
||||
import Debug from 'debug';
|
||||
const debug = Debug("image");
|
||||
|
||||
const a = require("./Ansi.js");
|
||||
import a from './Ansi.mjs';
|
||||
|
||||
function calculate_size(width, height, size_spec) {
|
||||
if(size_spec.indexOf("%") > -1) {
|
||||
|
@ -34,7 +38,6 @@ var queue = null;
|
|||
|
||||
async function make_queue() {
|
||||
// 1: Setup task queue
|
||||
const PQueue = (await import("p-queue")).default;
|
||||
let concurrency = os.cpus().length;
|
||||
if(process.env["MAX_CONCURRENT"])
|
||||
concurrency = parseInt(process.env["MAX_CONCURRENT"], 10);
|
||||
|
@ -142,16 +145,8 @@ async function picture(source_image, alt, target_dir, urlpath, formats = "__AUTO
|
|||
return result;
|
||||
}
|
||||
|
||||
var picture_memoize = null;
|
||||
var pretty_ms;
|
||||
var picture_memoize = pMemoize(picture);
|
||||
|
||||
async function setup_memoize() {
|
||||
const pMemoize = (await import("p-memoize")).default;
|
||||
picture_memoize = pMemoize(picture);
|
||||
}
|
||||
|
||||
module.exports = async function(...args) {
|
||||
if(picture_memoize === null) await setup_memoize();
|
||||
pretty_ms = (await import("pretty-ms")).default;
|
||||
export default async function(...args) {
|
||||
return await picture_memoize(...args);
|
||||
};
|
|
@ -1,14 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
const promisify = require("util").promisify;
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const child_process = require("child_process");
|
||||
import { promisify } from "util";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import child_process from "child_process";
|
||||
|
||||
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great!
|
||||
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
|
||||
|
||||
const filepath_moondoc = path.resolve(__dirname, `../node_modules/.bin/moondoc`);
|
||||
const dirpath_root = path.resolve(__dirname, `../..`);
|
||||
|
||||
module.exports = function moondoc_runner(filepath_output) {
|
||||
export default function moondoc_runner(filepath_output) {
|
||||
const dirpath = path.dirname(filepath_output);
|
||||
if(!fs.existsSync(dirpath)) {
|
||||
fs.mkdirSync(dirpath, { recursive: true });
|
|
@ -1,14 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
const crypto = require("crypto");
|
||||
import crypto from "crypto";
|
||||
|
||||
const htmlentities = require("html-entities");
|
||||
const markdown = require("markdown-it")({
|
||||
import htmlentities from "html-entities";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import chroma from "chroma-js";
|
||||
|
||||
import markdown_prism from "markdown-it-prism";
|
||||
import markdown_alerts from "markdown-it-github-alerts";
|
||||
|
||||
const markdown = new MarkdownIt({
|
||||
xhtmlOut: true
|
||||
});
|
||||
const chroma = require("chroma-js");
|
||||
|
||||
const markdown_prism = require("markdown-it-prism");
|
||||
markdown.use(markdown_prism, {
|
||||
init: (Prism) => {
|
||||
Prism.languages.weacmd = {
|
||||
|
@ -21,8 +25,7 @@ markdown.use(markdown_prism, {
|
|||
}
|
||||
});
|
||||
|
||||
const alerts = require("markdown-it-github-alerts");
|
||||
markdown.use(alerts);
|
||||
markdown.use(markdown_alerts);
|
||||
|
||||
function extract_title(line) {
|
||||
return line.match(/#+\s+(.+)\s*/)[1].replace(/^`*|`*$/g, "")
|
||||
|
@ -47,7 +50,7 @@ function make_section(acc, cat_current, cats) {
|
|||
};
|
||||
}
|
||||
|
||||
module.exports = function parse_sections(source) {
|
||||
export default function parse_sections(source) {
|
||||
const cats = new Map();
|
||||
source.match(/^##\s+.*$/gm)
|
||||
.map(extract_title)
|
33
.docs/package-lock.json
generated
33
.docs/package-lock.json
generated
|
@ -10,7 +10,6 @@
|
|||
"license": "MPL-2.0",
|
||||
"dependencies": {
|
||||
"@11ty/eleventy": "^3.0.0",
|
||||
"@11ty/eleventy-upgrade-help": "^3.0.1",
|
||||
"chroma-js": "^3.1.1",
|
||||
"clean-css": "^5.3.2",
|
||||
"columnify": "^1.6.0",
|
||||
|
@ -163,26 +162,6 @@
|
|||
"url": "https://opencollective.com/11ty"
|
||||
}
|
||||
},
|
||||
"node_modules/@11ty/eleventy-upgrade-help": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-upgrade-help/-/eleventy-upgrade-help-3.0.1.tgz",
|
||||
"integrity": "sha512-69CttBBfplByurn5vW7eRiLPywZZZHCH6B68Ib3t3348PaHHG9RysVPRqPQzMrGIEEbXg+0+ICm+R8sAkgjfPQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fast-glob": "^3.3.2",
|
||||
"kleur": "^4.1.5",
|
||||
"minimist": "^1.2.8",
|
||||
"posthtml-match-helper": "^2.0.2",
|
||||
"semver": "^7.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/11ty"
|
||||
}
|
||||
},
|
||||
"node_modules/@11ty/eleventy-utils": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.3.tgz",
|
||||
|
@ -3351,18 +3330,6 @@
|
|||
"posthtml-match-helper": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"@11ty/eleventy-upgrade-help": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-upgrade-help/-/eleventy-upgrade-help-3.0.1.tgz",
|
||||
"integrity": "sha512-69CttBBfplByurn5vW7eRiLPywZZZHCH6B68Ib3t3348PaHHG9RysVPRqPQzMrGIEEbXg+0+ICm+R8sAkgjfPQ==",
|
||||
"requires": {
|
||||
"fast-glob": "^3.3.2",
|
||||
"kleur": "^4.1.5",
|
||||
"minimist": "^1.2.8",
|
||||
"posthtml-match-helper": "^2.0.2",
|
||||
"semver": "^7.6.3"
|
||||
}
|
||||
},
|
||||
"@11ty/eleventy-utils": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.3.tgz",
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"homepage": "https://github.com/sbrl/Minetest-WorldEditAdditions#readme",
|
||||
"dependencies": {
|
||||
"@11ty/eleventy": "^3.0.0",
|
||||
"@11ty/eleventy-upgrade-help": "^3.0.1",
|
||||
"chroma-js": "^3.1.1",
|
||||
"clean-css": "^5.3.2",
|
||||
"columnify": "^1.6.0",
|
||||
|
|
Loading…
Reference in a new issue