profectus-docs/.vitepress/config.js

107 lines
3.8 KiB
JavaScript
Raw Normal View History

2022-03-08 01:03:11 -06:00
const fs = require("fs");
2022-02-28 19:51:29 -06:00
module.exports = {
lang: "en-US",
title: 'Profectus',
description: 'A game engine that grows with you.',
2022-02-28 22:08:36 -06:00
head: [
2022-03-05 22:34:42 -06:00
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Roboto+Mono:ital@0;1' }],
2022-03-02 19:35:06 -06:00
['link', { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }],
['link', { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' }],
['link', { rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png' }],
2022-03-02 19:40:52 -06:00
['link', { rel: 'manifest', href: '/site.webmanifest' }],
2022-03-02 19:55:07 -06:00
['script', { defer: true, 'data-domain': 'moddingtree.com', src: 'https://plausible.io/js/plausible.js' }],
['meta', { name: 'og:description', content: 'A game engine that grows with you' }],
['meta', { name: 'og:image', content: '/Logo.png' }]
2022-02-28 22:08:36 -06:00
],
2022-02-28 19:51:29 -06:00
themeConfig: {
2022-02-28 22:08:36 -06:00
repo: 'profectus-engine/profectus-docs',
docsDir: '',
docsBranch: 'main',
editLinks: true,
editLinkText: 'Edit this page on GitHub',
lastUpdated: 'Last Updated',
2022-02-28 19:51:29 -06:00
nav: [
2022-02-28 22:08:36 -06:00
{ text: "Guide", link: "/guide/", activeMatch: "^/guide/" },
2022-02-28 23:50:38 -06:00
{ text: "API", link: "/api/", activeMatch: "^/api/" },
2022-02-28 19:51:29 -06:00
{ text: "Forums", link: "https://forums.moddingtree.com" },
{ text: "Discord", link: "https://discord.gg/F3xveHV" },
{ text: "Github", link: "https://github.com/profectus-engine/Profectus" }
],
2022-02-28 23:50:38 -06:00
sidebar: {
"/guide/": [
2022-02-28 22:08:36 -06:00
{
2022-03-02 19:28:57 -06:00
text: "Getting Started",
2022-02-28 22:08:36 -06:00
children: [
{ text: "Introduction", link: "/guide/" },
2022-03-02 19:28:57 -06:00
{ text: "Setting Up", link: "/guide/setup" },
{ text: "Updating Profectus", link: "/guide/updating" }
]
},
{
text: "Creating Your Project",
children: [
{ text: "Project Info", link: "/guide/project-info" },
{ text: "Project Entry", link: "/guide/project-entry" },
{ text: "Changelog", link: "/guide/changelog" },
2022-03-05 22:34:42 -06:00
{ text: "Themes", link: "/guide/themes" },
{ text: "Utilities", link: "/guide/utils" }
]
},
{
text: "Important Concepts",
children: [
{ text: "Layers", link: "/guide/layers" },
{ text: "Features", link: "/guide/features" },
{ text: "Coercable Components", link: "/guide/coercable" },
{ text: "Reactivity", link: "/guide/reactivity" }
2022-02-28 22:08:36 -06:00
]
},
{
2022-03-05 22:34:42 -06:00
text: "Advanced Concepts",
children: [
{ text: "Creating Features", link: "/guide/creating-features" }
]
2022-02-28 22:08:36 -06:00
}
2022-02-28 23:50:38 -06:00
],
2022-03-08 01:03:11 -06:00
"/api/": generateAPISidebar()
2022-02-28 23:50:38 -06:00
}
2022-02-28 19:51:29 -06:00
}
}
2022-03-08 01:03:11 -06:00
function generateAPISidebar() {
const modules = fs.readdirSync("./api/modules").map(file => file.substr(0, file.length - 3));
const folders = {};
modules.forEach(file => {
// Split by _, but not break_eternity
const pieces = file.replace("break_eternity", "break~eternity").split(/_/).map(piece => piece === "break~eternity" ? "break_eternity" : piece);
const lineItem = { text: camelToTitle(pieces[pieces.length - 1]), link: `/api/modules/${file}` };
pieces.slice(0, pieces.length - 1).reduce((acc, curr) => {
// console.log(acc, curr);
if (!acc[curr]) {
acc[curr] = { text: camelToTitle(curr), children: [] };
}
return acc[curr].children;
}, folders).push(lineItem);
});
return processFolders(folders);
}
function camelToTitle(camel) {
if (camel === "break_eternity") {
return "Break Eternity";
}
let title = camel.replace(/([A-Z])/g, " $1");
title = title.charAt(0).toUpperCase() + title.slice(1);
return title;
}
function processFolders(folders) {
return Object.values(folders).map(folder => {
if (folder.children) {
folder.children = processFolders(folder.children);
}
return folder;
})
}