@@ -4,12 +4,16 @@ import type * as Preset from '@docusaurus/preset-classic';
44
55// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
66
7+ const typesenseEnabled = Boolean (
8+ process . env . TYPESENSE_HOST && process . env . TYPESENSE_SEARCH_API_KEY ,
9+ ) ;
10+
711const config : Config = {
812 title : 'PascalCTF Wiki' ,
913 tagline : 'A wiki made for beginners to learn CTF and cybersecurity' ,
1014 favicon : 'img/favicon.ico' ,
1115
12- themes : [ 'docusaurus-theme-search-typesense' ] ,
16+ themes : typesenseEnabled ? [ 'docusaurus-theme-search-typesense' ] : [ ] ,
1317
1418 // Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
1519 future : {
@@ -62,26 +66,30 @@ const config: Config = {
6266 colorMode : {
6367 respectPrefersColorScheme : true ,
6468 } ,
65- typesense : {
66- // Must match `index_name` in the scraper config.
67- typesenseCollectionName :
68- process . env . TYPESENSE_COLLECTION_NAME ?? 'training-wiki' ,
69+ ...( typesenseEnabled
70+ ? {
71+ typesense : {
72+ // Must match `index_name` in the scraper config.
73+ typesenseCollectionName :
74+ process . env . TYPESENSE_COLLECTION_NAME ?? 'training-wiki' ,
6975
70- typesenseServerConfig : {
71- nodes : [
72- {
73- host : process . env . TYPESENSE_HOST ?? 'localhost' ,
74- port : Number ( process . env . TYPESENSE_PORT ?? '8108' ) ,
75- protocol : ( process . env . TYPESENSE_PROTOCOL ?? 'http' ) as
76- | 'http'
77- | 'https' ,
76+ typesenseServerConfig : {
77+ nodes : [
78+ {
79+ host : process . env . TYPESENSE_HOST ! ,
80+ port : Number ( process . env . TYPESENSE_PORT ?? '8108' ) ,
81+ protocol : ( process . env . TYPESENSE_PROTOCOL ?? 'http' ) as
82+ | 'http'
83+ | 'https' ,
84+ } ,
85+ ] ,
86+ apiKey : process . env . TYPESENSE_SEARCH_API_KEY ! ,
87+ } ,
88+ typesenseSearchParameters : { } ,
89+ contextualSearch : true ,
7890 } ,
79- ] ,
80- apiKey : process . env . TYPESENSE_SEARCH_API_KEY ?? 'xyz' ,
81- } ,
82- typesenseSearchParameters : { } ,
83- contextualSearch : true ,
84- } ,
91+ }
92+ : { } ) ,
8593 navbar : {
8694 title : 'Training Wiki' ,
8795 logo : {
@@ -179,7 +187,7 @@ const config: Config = {
179187 darkTheme : prismThemes . dracula ,
180188 } ,
181189 } satisfies ( Preset . ThemeConfig & {
182- typesense : {
190+ typesense ? : {
183191 typesenseCollectionName : string ;
184192 typesenseServerConfig : {
185193 nodes : Array < { host : string ; port : number ; protocol : 'http' | 'https' } > ;
0 commit comments