Skip to content

Commit

Permalink
docs: upgrade Vitepress (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Jan 30, 2024
1 parent e119645 commit 28f785d
Show file tree
Hide file tree
Showing 5 changed files with 615 additions and 566 deletions.
2 changes: 2 additions & 0 deletions .changeset/afraid-rockets-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
11 changes: 10 additions & 1 deletion apps/docs/.vitepress/theme/styles/custom.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
:root {
--vp-c-brand-1: var(--vp-c-green-1);
--vp-c-brand-2: var(--vp-c-green-2);
--vp-c-brand-3: var(--vp-c-green-3);
--vp-c-brand-soft: var(--vp-c-green-soft);
}

.VPNavBarSearch {
margin-right: auto;
}
Expand All @@ -24,7 +31,9 @@
left: -0.2rem;
opacity: 0;
transform: translateX(-100%);
transition: color 0.25s, opacity 0.25s;
transition:
color 0.25s,
opacity 0.25s;
color: var(--vp-c-brand);
}

Expand Down
5 changes: 3 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "docs",
"version": "0.43.11",
"description": "",
"type": "module",
"scripts": {
"dev": "nodemon --config nodemon.config.json -x 'pnpm run docs && vitepress dev'",
"build": "pnpm run docs && vitepress build",
Expand All @@ -27,8 +28,8 @@
"replace": "^1.2.2",
"typedoc": "^0.25.1",
"typedoc-plugin-merge-modules": "^5.0.1",
"vitepress": "1.0.0-alpha.51",
"vitepress": "1.0.0-rc.40",
"vitepress-plugin-search": "1.0.4-alpha.19",
"vue": "^3.2.47"
"vue": "^3.4.15"
}
}
16 changes: 9 additions & 7 deletions apps/docs/scripts/typedoc-postbuild.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readdirSync, mkdirSync, copyFileSync, renameSync, writeFileSync, rmSync } from 'fs';
import { join } from 'path';
import { join, dirname } from 'path';
import replace from 'replace';
import { fileURLToPath } from 'url';

type Link = {
link: string;
Expand All @@ -17,7 +18,8 @@ type RegexReplacement = {
/**
* Post build script to trim off undesired leftovers from Typedoc, restructure directories and generate json for links.
*/
const docsDir = join(__dirname, '../src/');
const filename = fileURLToPath(import.meta.url);
const docsDir = join(dirname(filename), '../src/');
const apiDocsDir = join(docsDir, '/api');
const classesDir = join(apiDocsDir, '/classes');
const modulesDir = join(apiDocsDir, '/modules');
Expand Down Expand Up @@ -45,8 +47,8 @@ const removeUnwantedFiles = () =>
rmSync(fullDirPath, { recursive: true, force: true });
});

const renameInterfaces = async () => {
await renameSync(join(apiDocsDir, 'interfaces'), join(apiDocsDir, 'interfaces_typedoc'));
const renameInterfaces = () => {
renameSync(join(apiDocsDir, 'interfaces'), join(apiDocsDir, 'interfaces_typedoc'));
};

/**
Expand Down Expand Up @@ -80,7 +82,7 @@ const exportLinksJson = () => {
/**
* Alters the typedoc generated file structure to be more semantic.
*/
const alterFileStructure = async () => {
const alterFileStructure = () => {
const modulesFiles = readdirSync(modulesDir);
const classesFiles = readdirSync(classesDir);
const interfacesFiles = readdirSync(interfacesDir);
Expand All @@ -92,7 +94,7 @@ const alterFileStructure = async () => {
...enumsFiles.map((e) => ({ name: e, path: enumsDir })),
];

await modulesFiles.forEach((modulesFile) => {
modulesFiles.forEach((modulesFile) => {
// Create a new directory for each module
const newDirName = modulesFile.split('.')[0];
const newDirPath = join(apiDocsDir, newDirName);
Expand Down Expand Up @@ -167,7 +169,7 @@ const recreateInternalLinks = () => {

const main = async () => {
log('Cleaning up API docs.');
await renameInterfaces();
renameInterfaces();
await alterFileStructure();
removeUnwantedFiles();
exportLinksJson();
Expand Down
Loading

0 comments on commit 28f785d

Please sign in to comment.