chore: refactor config

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-11-05 23:01:28 +01:00
parent bca52fdc0e
commit b94c33faaa
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -9,13 +9,19 @@ const katex = require("rehype-katex");
require("dotenv").config(); require("dotenv").config();
function constructDocs(subject) { class Subject {
constructor(subject, description) {
this.subject = subject;
this.description = description;
}
docs() {
return [ return [
"@docusaurus/plugin-content-docs", "@docusaurus/plugin-content-docs",
{ {
id: subject, id: this.subject,
path: subject, path: this.subject,
routeBasePath: subject, routeBasePath: this.subject,
sidebarPath: require.resolve("./sidebars.js"), sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://gitlab.fi.muni.cz/xfocko/kb/tree/main", editUrl: "https://gitlab.fi.muni.cz/xfocko/kb/tree/main",
remarkPlugins: [math], remarkPlugins: [math],
@ -24,6 +30,26 @@ function constructDocs(subject) {
]; ];
} }
navbar() {
return {
type: "doc",
docId: `${this.subject}-intro`,
docsPluginId: this.subject,
position: "left",
label: `${this.subject.toUpperCase()}: ${this.description}`,
};
}
}
const subjects = [
new Subject("ib002", "Algorithms"),
// new Subject("ib015", "Non-imperative programming"),
// new Subject("ib110", "Introduction to informatics"),
// new Subject("ib111", "Foundations of programming"),
new Subject("pb071", "C"),
new Subject("pb161", "C++"),
];
/** @type {import('@docusaurus/types').Config} */ /** @type {import('@docusaurus/types').Config} */
const config = { const config = {
title: "Additional materials by mf", title: "Additional materials by mf",
@ -53,7 +79,7 @@ const config = {
], ],
], ],
plugins: ["ib002", "ib015", "ib110", "ib111", "pb071", "pb161"].map(constructDocs), plugins: subjects.map(s => s.docs()),
stylesheets: [ stylesheets: [
{ {
@ -71,48 +97,7 @@ const config = {
navbar: { navbar: {
title: "Additional materials by mf", title: "Additional materials by mf",
items: [ items: [
{ ...subjects.map(s => s.navbar()),
type: "doc",
docId: "ib002-intro",
docsPluginId: "ib002",
position: "left",
label: "IB002: Algorithms",
},
// {
// type: "doc",
// docId: "ib015-intro",
// docsPluginId: "ib015",
// position: "left",
// label: "IB015: Non-imperative programming",
// },
// {
// type: "doc",
// docId: "ib110-intro",
// docsPluginId: "ib110",
// position: "left",
// label: "IB110: Introduction to informatics",
// },
// {
// type: "doc",
// docId: "ib111-intro",
// docsPluginId: "ib111",
// position: "left",
// label: "IB111: Foundations of programming",
// },
{
type: "doc",
docId: "pb071-intro",
docsPluginId: "pb071",
position: "left",
label: "PB071: C",
},
{
type: "doc",
docId: "pb161-intro",
docsPluginId: "pb161",
position: "left",
label: "PB161: C++",
},
{ {
href: "https://gitlab.fi.muni.cz/xfocko/fi", href: "https://gitlab.fi.muni.cz/xfocko/fi",
label: "GitLab", label: "GitLab",