2021-10-17 02:00:24 +00:00
|
|
|
"use strict";
|
2024-10-01 23:55:24 +00:00
|
|
|
import fs from "fs";
|
|
|
|
import path from "path";
|
2021-10-17 02:00:24 +00:00
|
|
|
|
2024-10-01 23:55:24 +00:00
|
|
|
import columnify from "columnify";
|
|
|
|
import htmlentities from "html-entities";
|
2021-10-17 02:00:24 +00:00
|
|
|
|
2024-10-01 23:55:24 +00:00
|
|
|
import a from "./lib/Ansi.mjs";
|
|
|
|
import parse_sections from "./lib/parse_sections.mjs";
|
2021-10-17 02:00:24 +00:00
|
|
|
|
2024-10-01 23:55:24 +00:00
|
|
|
// 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("/"));
|
2021-06-20 00:51:55 +00:00
|
|
|
|
2024-10-02 00:06:56 +00:00
|
|
|
const { sections, categories } = parse_sections(fs.readFileSync(
|
2021-10-05 01:02:53 +00:00
|
|
|
path.resolve(
|
|
|
|
__dirname,
|
|
|
|
`../Chat-Command-Reference.md`
|
|
|
|
),
|
|
|
|
"utf-8"
|
|
|
|
))
|
2021-06-20 00:51:55 +00:00
|
|
|
|
2024-10-02 00:06:56 +00:00
|
|
|
sections.sort((a, b) => a.title.replace(/^\/+/g, "").localeCompare(
|
2021-10-05 01:02:53 +00:00
|
|
|
b.title.replace(/^\/+/g, "")));
|
2021-06-20 00:51:55 +00:00
|
|
|
|
2021-10-05 01:02:53 +00:00
|
|
|
|
|
|
|
console.log(`REFERENCE SECTION TITLES`)
|
2021-10-17 02:00:24 +00:00
|
|
|
console.log(columnify(sections.map(s => { return {
|
|
|
|
category: `${a.hicol}${a.fyellow}${s.category}${a.reset}`,
|
|
|
|
command: `${a.hicol}${a.fmagenta}${htmlentities.decode(s.title)}${a.reset}`
|
|
|
|
} })));
|
|
|
|
// console.log(sections
|
|
|
|
// .map(s => `${a.fyellow}${a.hicol}${s.category}${a.reset}\t${a.fmagenta}${a.hicol}${s.title}${a.reset}`).join(`\n`));
|
2021-10-05 01:02:53 +00:00
|
|
|
console.log(`************************`);
|
|
|
|
|
2021-10-17 02:00:24 +00:00
|
|
|
console.log(`REFERENCE SECTION COLOURS`);
|
|
|
|
console.log(columnify(Array.from(categories).map(el => { return {
|
|
|
|
category: el[0],
|
|
|
|
colour: el[1]
|
|
|
|
} })));
|
|
|
|
|
2024-10-01 23:55:24 +00:00
|
|
|
export default {
|
2021-06-20 00:51:55 +00:00
|
|
|
layout: "theme.njk",
|
|
|
|
title: "Reference",
|
|
|
|
tags: "navigable",
|
|
|
|
date: "2001-01-01",
|
|
|
|
section_intro: sections[0],
|
2021-10-05 01:02:53 +00:00
|
|
|
sections_help: sections, // Remove the very beginning bit
|
|
|
|
categories: [...categories.keys()].join("|")
|
2021-06-20 00:51:55 +00:00
|
|
|
}
|