codePreviews: file type aliases

This commit is contained in:
Cynthia Foxwell 2024-06-01 23:17:43 -06:00
parent 8fcbb1315c
commit 34dd8d4464
1 changed files with 24 additions and 1 deletions

View File

@ -23,6 +23,27 @@ function unindent(str) {
return str.replace(new RegExp(`^ {${minIndent}}`, "gm"), "");
}
const fileTypeAliases = {
astro: "jsx",
svelte: "jsx",
vue: "jsx",
mdx: "md",
jsonc: "json",
json5: "json",
jsonld: "json",
"sublime-build": "json",
"sublime-settings": "json",
"sublime-menu": "json",
"sublime-commands": "json",
"sublime-project": "json",
"sublime-mousemap": "json",
"sublime-keymap": "json",
"sublime-macro": "json",
"sublime-completions": "json",
"code-workspace": "json",
"code-snippets": "json",
};
async function processFile(
link,
originalLink,
@ -96,7 +117,9 @@ async function processFile(
return `**${fileName}:** ${whichLines}${warning}\n${
spoiler ? "||" : ""
}\`\`\`${fileType}\n${unindent(targetLines)}\n\`\`\`${spoiler ? "||" : ""}`;
}\`\`\`${fileTypeAliases[fileType] ?? fileType}\n${unindent(
targetLines
)}\n\`\`\`${spoiler ? "||" : ""}`;
}
events.add("messageCreate", "codePreviews", async function (msg) {