Skip to content

Commit bbcb2bf

Browse files
committed
feat: update ModeWatcher default mode and enhance OpenAPI configuration options
1 parent 4bf920e commit bbcb2bf

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/routes/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<meta name="twitter:image" content={ogImage} />
3535
</svelte:head>
3636

37-
<ModeWatcher />
37+
<ModeWatcher defaultMode={'dark'} />
3838

3939
<div
4040
class="min-h-screen bg-white text-gray-900 transition-colors dark:bg-gray-950 dark:text-gray-100"

src/routes/+page.svelte

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import githubDark from 'svelte-highlight/styles/github-dark';
1919
import oneCLight from 'svelte-highlight/styles/1c-light';
2020
import { mode } from 'mode-watcher';
21+
import { onMount } from 'svelte';
2122
2223
// State for copy buttons
2324
let copiedStates = $state({
@@ -115,14 +116,33 @@ import openapiPlugin from 'sveltekit-openapi-generator';
115116
export default defineConfig({
116117
plugins: [
117118
openapiPlugin({
118-
baseSchemasPath: 'src/lib/schemas.js',
119-
prependPath: '/api',
119+
// OpenAPI info section
120120
info: {
121121
title: 'My API',
122122
version: '1.0.0',
123123
description: 'My API Description'
124124
},
125-
outputPath: 'static/openapi.json'
125+
// OpenAPI servers configuration
126+
servers: [
127+
{ url: 'https://api.example.com', description: 'Production' },
128+
{ url: 'http://localhost:5173', description: 'Development' }
129+
],
130+
// Path to shared schema definitions
131+
baseSchemasPath: 'src/lib/schemas.js',
132+
// Additional YAML files to include
133+
yamlFiles: ['src/lib/extra-specs.yaml'],
134+
// Path prefix for all routes
135+
prependPath: '/api',
136+
// Glob patterns to include
137+
include: ['src/routes/**/{+server,+page.server}.{js,ts}'],
138+
// Glob patterns to exclude
139+
exclude: ['**/node_modules/**', '**/.svelte-kit/**'],
140+
// Whether to fail on JSDoc parsing errors
141+
failOnErrors: false,
142+
// Output path for the spec file during build
143+
outputPath: 'static/openapi.json',
144+
// Debounce delay in milliseconds for file watching
145+
debounceMs: 200
126146
}),
127147
sveltekit()
128148
]
@@ -239,6 +259,10 @@ export async function GET({ url }) {
239259
description: 'Easy integration with Swagger UI for beautiful, interactive API documentation.'
240260
}
241261
];
262+
let theme: string = $state('');
263+
onMount(() => {
264+
theme = mode.current === 'dark' ? githubDark : oneCLight;
265+
});
242266
</script>
243267

244268
<svelte:head>
@@ -247,7 +271,7 @@ export async function GET({ url }) {
247271
name="description"
248272
content="Automatically generate OpenAPI 3.0 specifications from your SvelteKit server endpoints using JSDoc @swagger annotations. Hot Module Replacement, TypeScript support, and more."
249273
/>
250-
{@html mode.current === 'dark' ? githubDark : oneCLight}
274+
{@html theme}
251275
</svelte:head>
252276

253277
<!-- Hero Section -->

0 commit comments

Comments
 (0)