Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 [docs] Move of documentation to vitepress #2951

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
"markdownlint/md033": ["error", {
"allowed_elements": [
"discord",
"a"
"span"
] // These are Vue elements used in the docs
}],
// Bare URL used
Expand Down
1 change: 1 addition & 0 deletions docsvite/.vitepress/.temp/.modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions docsvite/.vitepress/.temp/.versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"beta":"4.7.12+20240313.0709","stable":"4.7.12+20240308.1952","short":"4.7.12"}
134 changes: 134 additions & 0 deletions docsvite/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import fs from 'fs';
import path from 'path';

import { defineConfig } from 'vitepress'
import { createRequire } from 'node:module'

import childProcess from './utils/childProcess';
import config from '../../src/config';
import getConstants from './utils/getConstants';
import i18n from './utils/i18n';
import localeConfig, {
type LocaleSiteConfig,
type LocaleThemeConfig,
} from './utils/localeConfig';

import type { Versions } from './utils/generate/versions';
const require = createRequire(import.meta.url)

const {
DOCS_URL,
BASE,
VITEPRESS_PATH,
ROOT_PATH,
MODULES_PATH,
DIST_PATH,
DOCS_PATH,
DOCS_DIST_PATH,
DOCS_TEMP_PATH,
DOCS_I18N_PATH,
DOCS_UTILS_PATH,
DOCS_COMPONENTS_PATH,
LANGS,
MODULES,
} = getConstants();

const { run } = childProcess(DOCS_UTILS_PATH);

const sidebar_lssm = ['', 'metadata'];
const sidebar_others = [
'suggestions',
'support',
'error_report',
'faq',
'bugs',
'appstore',
'settings',
'other',
];

// Generate versions

const versionsFile = path.join(DOCS_TEMP_PATH, '.versions.json');
run('generate/versions', versionsFile);
const versions: Versions = JSON.parse(fs.readFileSync(versionsFile).toString());


// Generate modules

const modulesFile = path.join(DOCS_TEMP_PATH, '.modules.json');

// Generate i18n

const $t = i18n(DOCS_I18N_PATH);
const getLocaleConfig = localeConfig(
$t,
sidebar_lssm,
sidebar_others,
JSON.parse(fs.readFileSync(modulesFile).toString()),
DOCS_PATH
);

const localeConfigs: {
siteConfigs: Record<`/${string}/`, LocaleSiteConfig>;
themeConfigs: Record<`/${string}/`, LocaleThemeConfig>;
searchConfigs: Record<`/${string}/`, { placeholder: string }>;
pwaPopupConfigs: Record<
`/${string}/`,
{ message: string; buttonText: string }
>;
} = {
siteConfigs: {},
themeConfigs: {},
searchConfigs: {},
pwaPopupConfigs: {},
};

LANGS.forEach(lang => {
const { siteConfig, themeConfig, searchPlaceholder, pwaPopupConfig } =
getLocaleConfig(lang);
localeConfigs.siteConfigs[`${lang}`] = siteConfig;
localeConfigs.themeConfigs[`/${lang}/`] = themeConfig;
localeConfigs.searchConfigs[`/${lang}/`] = {
placeholder: searchPlaceholder,
};
localeConfigs.pwaPopupConfigs[`/${lang}/`] = pwaPopupConfig;
});
localeConfigs.siteConfigs['root'] = localeConfigs.siteConfigs['en_US'];

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "LSS-Manager V.4 Wiki",
description: "The Wiki for LSS-Manager V.4",
outDir: "../dist/docs",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: `v${versions.short}`, link: `https://github.com/${config.github.repo}/releases/tag/v${versions.short}` }
],

sidebar: {},

socialLinks: [
{ icon: 'github', link: `https://github.com/${config.github.repo}` },
{ icon: 'discord', link: `https://discord.gg/${config.discord.invite}` }
]
},
locales: localeConfigs.siteConfigs ,
srcDir: 'src',
rewrites: {
'modules/:module/docs/:lang.md': ':lang/modules/:module.md',
'modules/:module/docs/assets/:lang/:file': ':lang/modules/:file'
},
ignoreDeadLinks: true, //TODO: Remove this line when all links are fixed

// This allows the server renderer to be found. Even inside the modules directory which is outside the workspace
vite: {
resolve: {
alias: {
'vue/server-renderer': require.resolve('vue/server-renderer'),
'vue': require.resolve('vue')
}
}
}
})
Loading