From 71feb7e9c322ddfb9505fb5fc17b3c395d06758e Mon Sep 17 00:00:00 2001 From: DuroCodes Date: Mon, 6 May 2024 21:26:17 -0400 Subject: [PATCH] fix: add checking for typedoc file --- astro.config.mjs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 079795c04..313da2922 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -4,6 +4,13 @@ import starlightBlog from 'starlight-blog'; import tailwind from "@astrojs/tailwind"; import starlightDocSearch from '@astrojs/starlight-docsearch'; import starlightTypeDoc, { typeDocSidebarGroup } from 'starlight-typedoc'; +import { existsSync } from 'fs'; + +const typedocFileExists = existsSync('../sern-handler/tsconfig.json'); + +if (!typedocFileExists) { + console.warn('No typedoc file found. Skipping typedoc integration. If you want to use typedoc, make sure to have `sern-handler` in the parent directory.'); +} export default defineConfig({ integrations: [starlight({ @@ -48,15 +55,6 @@ export default defineConfig({ apiKey: 'ccfe6abc4d12ac6f882565a9d0caafb1', indexName: 'sern', }), - starlightTypeDoc({ - // If you're editing the website, you should probably change this to your local sern installation - entryPoints: ['../sern-handler/src/index.ts'], - tsconfig: '../sern-handler/tsconfig.json', - sidebar: { - collapsed: true, - }, - typeDocSidebarGroup, - }), starlightBlog({ authors: { jacoobes: { @@ -90,6 +88,12 @@ export default defineConfig({ }, } }), - ], + typedocFileExists ? starlightTypeDoc({ + tsconfig: '../sern-handler/tsconfig.json', + autogenerate: { + directory: 'api', + }, + }) : null, + ].filter(Boolean), }), tailwind()] }); \ No newline at end of file