profectus-docs/docs/.vitepress/config.js

168 lines
8.8 KiB
JavaScript
Raw Normal View History

2022-03-08 07:03:11 +00:00
const fs = require("fs");
2022-03-11 02:30:55 +00:00
const path = require("path");
2022-03-08 07:03:11 +00:00
2022-03-01 01:51:29 +00:00
module.exports = {
lang: "en-US",
title: 'Profectus',
description: 'A game engine that grows with you.',
2022-03-01 04:08:36 +00:00
head: [
2022-03-11 02:30:55 +00:00
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,400;0,600;1,400' }],
2022-03-03 01:35:06 +00: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-03 01:40:52 +00:00
['link', { rel: 'manifest', href: '/site.webmanifest' }],
2022-03-03 01:55:07 +00: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-03-01 04:08:36 +00:00
],
2022-07-14 05:25:11 +00:00
lastUpdated: true,
appearance: false,
2022-11-17 03:38:01 +00:00
cleanUrls: 'with-subfolders',
2022-03-01 01:51:29 +00:00
themeConfig: {
2022-07-14 05:25:11 +00:00
logo: "/favicon.svg",
editLink: {
pattern: "https://code.incremental.social/profectus/profectus-docs/edit/main/docs/:path",
editLinkText: "Edit this page on Incremental Social"
2022-07-14 05:25:11 +00:00
},
2022-03-01 01:51:29 +00:00
nav: [
2022-03-01 04:08:36 +00:00
{ text: "Guide", link: "/guide/", activeMatch: "^/guide/" },
2022-07-15 02:59:46 +00:00
{ text: "API", link: "/api/overview", activeMatch: "^/api/" },
2022-07-14 05:25:11 +00:00
{ text: "Forums", link: "https://forums.moddingtree.com" }
],
socialLinks: [
2023-04-20 22:07:43 +00:00
{ icon: "discord", link: "https://discord.gg/yJ4fjnjU54" },
{ icon: { svg: '<svg id="erAGSmQsg5F1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 334.73599 164" shape-rendering="geometricPrecision" text-rendering="geometricPrecision"><g transform="translate(-1.000199-.435301)"><path d="M271.24983,105.65061q-.36,4.08-.31,8.47.05,4.56-4.49,8.19-9.11,7.28-17.84-.35c-5.3-4.65-3.99-10.34-4.42-16.25-11.33-3.3-21.65-12.470005-22.8-24.590005q-.53-5.59-.95-11.21-.04-.52-.53-.64c-4.87-1.23-7.99-2.08-10.29-6.94-3.9-8.23.79-15.35,8.92-18.12.175893-.059771.287747-.229624.27-.41-.74-8.02-1.4-15.08,1.56-22.79c3.11-8.09,9.57-14.26,17.53-17.62q4.11-1.73,10.44-2.07q8.68-.46,17.4-.26q16.85.37,26.28,13.59c6.43,9.02,5.96,18.48,5.03,29.16q-.05.51.45.64c13.7,3.61,12.56,22.82-1.42,24.78-.330958.046125-.58496.316783-.61.65-.38,5.39-.17,11.34-2.1,16.46q-5.7,15.160005-22.12,19.310005Z" fill="#6b438b"/><path d="M142.39,41.700605l-31,11.57c-.187231.072269-.39801.046259-.563762-.069568s-.265293-.306667-.266238-.510432l.01-19.31q0-.55.51-.74q23.03-8.68,46.02-17.25c2.57-.96,4.78-.76,7.42-.75.129956,0,.254589.051625.346482.143518s.143518.216526.143518.346482v132.320005c.000017.211265-.084586.413735-.23491.56218s-.353842.230494-.56509.22782l-19.99-.01q-1.17,0-1.17-1.16v-104.910005c.000142-.1604-.078229-.310715-.209821-.40243s-.299742-.113219-.450179-.05757Z" fill="#eceff4"/><path d="M59.21,74.480605h33.95c.222782,0,.436439.0885.59397.24603s.24603.371188.24603.59397l-.01,18.96c0,.222782-.0885.436439-.24603.59397s-.371188.24603-.59397.24603l-33.88.03c-.222782,0-.436439.0885-.59397.24603s-.24603.371188-.24603.59397l-.08,38.580005c0,.222782-.0885.436439-.24603.59397s-.371188.24603-.59397.24603l-20.11-.01c-.222782,0-.436439-.0885-.59397-.24603s-.24603-.371188-.24603-.59397l-.01-38.580005c0-.222782-.0885-.436439-.24603-.59397s-.371188-.24603-.59397-.24603h-33.87c-.222782,0-.436439-.0885-.59397-.24603s-.24603-.371188-.24603-.59397l.02-19.02c0-.222782.0885-.436439.24603-.59397s.371188-.24603.59397-.24603l33.86.02c.222782,0,.436439-.0885.59397-.24603s.24603-.371188.24603-.59397v-35.79c0-.222782.0885-.436439.24603-.59397s.371188-.24603.59397-.24603l20.13-.02c.222782,0,.436439.0885.59397.24603s.24603.371188.24603.59397v35.83c0,.222782.0885.436439.24603.59397s.371188.24603.59397.24603Z" fill="#eceff4"/><path d="M244.18983,105.71061c.43,5.91-.88,11.6,4.42,16.25q8.73,7.63,17.84.35q4.54-3.63,4.49-8.19-.05-4.39.31-8.47q24.6,4,42.34,20.72l-.18,37.49-110.93.01-.09-37.61q17.53-16.43,41.8-20.55Z" fill="#533566"/><path d="M202.38983,126.26061l.09,37.61-21.38-.49c-.35821-.009824-.690529-.18897-.89563-.482816s-.258668-.667556-.14437-1.007184q7.21-21.29,22.33-35.63Z" fill="#6b438b"/><path d="M313.58983,126.37061q12.71,12.03,19.9,29.52q1.79,4.36,2.23,6.86.11.61-.51.62l-21.8.49.18-37.49Z" fill="#6b438b"/></g></svg>' }, link: "https://code.incremental.social/profectus/Profectus" }
2022-03-01 01:51:29 +00:00
],
2022-03-01 05:50:38 +00:00
sidebar: {
"/guide/": [
2022-03-01 04:08:36 +00:00
{
2022-03-03 01:28:57 +00:00
text: "Getting Started",
2023-04-05 12:44:37 +00:00
collapsed: false,
2022-07-14 05:25:11 +00:00
items: [
2022-03-01 04:08:36 +00:00
{ text: "Introduction", link: "/guide/" },
{ text: "Setting Up", link: "/guide/getting-started/setup" },
{ text: "Updating Profectus", link: "/guide/getting-started/updating" },
2023-04-19 03:58:07 +00:00
{ text: "Your First Layer", link: "/guide/getting-started/first-layer" },
2023-04-06 05:15:28 +00:00
{ text: "Example Projects", link: "/guide/getting-started/examples" },
{ text: "Profectus Changelog", link: "https://code.incremental.social/profectus/Profectus/blob/main/CHANGELOG.md" }
2022-03-03 01:28:57 +00:00
]
},
{
text: "Creating Your Project",
2023-04-05 12:44:37 +00:00
collapsed: false,
2022-07-14 05:25:11 +00:00
items: [
{ text: "Project Info", link: "/guide/creating-your-project/project-info" },
{ text: "Project Entry", link: "/guide/creating-your-project/project-entry" },
{ text: "Changelog", link: "/guide/creating-your-project/changelog" },
{ text: "Themes", link: "/guide/creating-your-project/themes" },
{ text: "Utilities", link: "/guide/creating-your-project/utils" }
2022-03-06 04:34:42 +00:00
]
},
{
text: "Important Concepts",
2023-04-05 12:44:37 +00:00
collapsed: false,
2022-07-14 05:25:11 +00:00
items: [
{ text: "Layers", link: "/guide/important-concepts/layers" },
{ text: "Features", link: "/guide/important-concepts/features" },
{ text: "Coercable Components", link: "/guide/important-concepts/coercable" },
{ text: "Reactivity", link: "/guide/important-concepts/reactivity" },
2023-04-08 01:49:31 +00:00
{ text: "Persistence", link: "/guide/important-concepts/persistence" },
2023-04-08 05:06:17 +00:00
{ text: "Requirements", link: "/guide/important-concepts/requirements" },
2023-04-08 01:49:31 +00:00
{ text: "Formulas", link: "/guide/important-concepts/formulas" }
2022-03-01 04:08:36 +00:00
]
},
{
text: "Recipes",
2023-04-05 12:44:37 +00:00
collapsed: false,
items: [
2023-04-19 04:20:45 +00:00
{ text: "Prestige Mechanic", link: "/guide/recipes/prestige" },
2023-04-10 02:40:12 +00:00
{ text: "Display Save Progress", link: "/guide/recipes/save-progress" },
{ text: "Display Particle Effect", link: "/guide/recipes/particles" }
]
},
2022-03-01 04:08:36 +00:00
{
2022-03-06 04:34:42 +00:00
text: "Advanced Concepts",
2023-04-05 12:44:37 +00:00
collapsed: false,
2022-07-14 05:25:11 +00:00
items: [
{ text: "Creating Features", link: "/guide/advanced-concepts/creating-features" },
2023-04-08 15:13:21 +00:00
{ text: "Dynamic Layers", link: "/guide/advanced-concepts/dynamic-layers" },
{ text: "Nodes", link: "/guide/advanced-concepts/nodes" }
2022-03-06 04:34:42 +00:00
]
2023-04-18 03:43:07 +00:00
},
{
text: "Migrations",
collapsed: true,
items: [
{ text: "0.5.X to 0.6.0", link: "/guide/migrations/0-6" }
]
2022-03-01 04:08:36 +00:00
}
2022-03-01 05:50:38 +00:00
],
2022-03-08 07:03:11 +00:00
"/api/": generateAPISidebar()
2022-03-01 05:50:38 +00:00
}
2022-03-01 01:51:29 +00:00
}
}
2022-03-08 07:03:11 +00:00
function generateAPISidebar() {
2022-03-11 03:10:53 +00:00
const sidebar = [];
const modules = fs.readdirSync("./docs/api/modules");
2022-03-08 07:03:11 +00:00
modules.forEach(file => {
2023-04-05 12:44:37 +00:00
const moduleSidebar = { text: camelToTitle(file), items: [], collapsed: file === "lib" };
2022-03-11 03:10:53 +00:00
sidebar.push(moduleSidebar)
2022-07-14 05:25:11 +00:00
walk(path.join("./docs/api/modules", file), moduleSidebar.items);
2022-03-11 02:30:55 +00:00
});
const componentFolders = [];
2022-03-11 03:10:53 +00:00
walk("./docs/api/components", componentFolders);
2022-03-11 02:30:55 +00:00
sidebar.unshift({
text: "Components",
2022-07-14 05:25:11 +00:00
collapsed: true,
items: componentFolders
2022-03-11 02:30:55 +00:00
});
sort(sidebar);
return sidebar;
}
function sort(sidebar) {
2022-07-14 05:25:11 +00:00
sidebar.filter(sidebar => !!sidebar.items).forEach(item => sort(item.items));
2022-03-11 02:30:55 +00:00
sidebar.sort((a, b) => {
2022-07-14 05:25:11 +00:00
if (a.items && !b.items) {
2022-03-11 02:30:55 +00:00
return -1;
2022-07-14 05:25:11 +00:00
} else if (!a.items && b.items) {
2022-03-11 02:30:55 +00:00
return 1;
} else if (a.text > b.text) {
return 1;
} else if (a.text < b.text) {
return -1;
} else {
return 0;
}
});
}
function walk(dir, sidebar) {
const files = fs.readdirSync(dir);
files.forEach(file => {
const resolvedFile = path.join(dir, file);
const stat = fs.statSync(resolvedFile);
if (stat.isDirectory()) {
2023-04-12 23:41:44 +00:00
const subSidebar = { text: camelToTitle(file), items: [], collapsed: true };
sidebar.push(subSidebar);
walk(resolvedFile, subSidebar.items);
2022-07-14 05:25:11 +00:00
} else if (!file.includes("Component") || dir.includes("components")) {
2022-03-11 03:10:53 +00:00
sidebar.push({ text: camelToTitle(file.substr(0, file.length - 3)), link: "/" + resolvedFile.substr(5, resolvedFile.length - 8).replace(/\\/g, "/") + ".html" });
2022-03-11 02:30:55 +00:00
}
2022-03-08 07:03:11 +00:00
});
}
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;
}