Skip to content

Commit 22de1a4

Browse files
committed
Tighten up glossary
1 parent 1d09f36 commit 22de1a4

File tree

8 files changed

+31
-663
lines changed

8 files changed

+31
-663
lines changed

packages/glossary/.gitignore

Whitespace-only changes.

packages/glossary/output/en.md

-240
This file was deleted.

packages/glossary/scripts/generateMarkdown.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*/
1616

17-
import { writeFileSync, readdirSync, existsSync, readFileSync, mkdirSync } from "fs";
17+
import { writeFileSync, readdirSync, existsSync, mkdirSync } from "fs";
1818
import { join } from "path";
1919
import * as assert from "assert";
2020
import { read as readMarkdownFile } from "gray-matter";
@@ -23,8 +23,6 @@ import * as prettier from "prettier";
2323
import * as remark from "remark";
2424
import * as remarkHTML from "remark-html";
2525

26-
const parseMarkdown = (md: string) => remark().use(remarkHTML).processSync(md);
27-
2826
const languages = readdirSync(join(__dirname, "..", "copy")).filter((f) => !f.startsWith("."));
2927

3028
const outputDir = join(__dirname, "..", "output");
@@ -34,6 +32,7 @@ languages.forEach((lang) => {
3432
const locale = join(__dirname, "..", "copy", lang);
3533
const fallbackLocale = join(__dirname, "..", "copy", "en");
3634

35+
const languageMeta = { terms: [] };
3736
const markdownChunks: string[] = [];
3837

3938
const glossaryTerms = readdirSync(join(__dirname, "..", "copy", "en")).filter(
@@ -65,19 +64,26 @@ languages.forEach((lang) => {
6564
const md = readMarkdownFile(glossaryMdPath);
6665
assert.ok(md.data.display, "No display data for term: " + filename);
6766

68-
markdownChunks.push(`\n### ${md.data.display}`);
67+
const termID = filename.split(".")[0].toLowerCase();
68+
const termDisplay = md.data.display;
69+
languageMeta.terms.push({ display: termDisplay, id: termID });
70+
71+
const title = `<h3 id='${termID}' ><a href='#${termID}' name='${termDisplay}' aria-label="Link to the section ${termDisplay}" aria-labelledby='${termID}'>#</a> ${termDisplay}</h3>`;
72+
markdownChunks.push(title);
73+
6974
markdownChunks.push(md.content);
7075
});
7176
});
7277
});
7378

74-
// const intro = parseMarkdown(readFileSync(getPathInLocale("intro.md"), "utf8"));
75-
// markdownChunks.push(intro + "\n");
76-
7779
// Write the Markdown and JSON
7880
const markdown = prettier.format(markdownChunks.join("\n"), { filepath: "index.md" });
7981
const mdPath = join(__dirname, "..", "output", lang + ".md");
8082
writeFileSync(mdPath, markdown);
83+
84+
const jsonInfo = prettier.format(JSON.stringify(languageMeta), { filepath: "index.json" });
85+
const jsonPath = join(__dirname, "..", "output", lang + ".json");
86+
writeFileSync(jsonPath, jsonInfo);
8187
});
8288

8389
writeFileSync(join(__dirname, "..", "output", "languages.json"), JSON.stringify({ languages }));

packages/glossary/scripts/lint.js

-7
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ languages.forEach((lang) => {
6464
errorReports.push({ path: optionPath, error: new Error("Did not have a 'display' property in the YML header") });
6565
}
6666

67-
if (!optionFile.data.tags) {
68-
hasError = true;
69-
// prettier-ignore
70-
71-
errorReports.push({ path: optionPath, error: new Error("Did not have a 'tags' property in the YML header") });
72-
}
73-
7467
const sigil = hasError ? cross : tick;
7568
const name = hasError ? chalk.red(option) : option;
7669
process.stdout.write(name + " " + sigil + ", ");

0 commit comments

Comments
 (0)