Skip to content

Commit cc23cd6

Browse files
committed
Fix errors preventing green build and dev server startup
1 parent de75113 commit cc23cd6

6 files changed

Lines changed: 51 additions & 58 deletions

File tree

public/logo.png

4.49 KB
Loading

src/components/Test/webComponent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export const registerWebComponent = async (tagName = TestWebComponent.registered
3838
defineCustomElement(tagName, TestWebComponent)
3939
}
4040

41+
// Backwards compatibility with older component script usage
42+
export const registerTestWebComponent = registerWebComponent
43+
4144
export const webComponentModule: WebComponentModule<TestWebComponent> = {
4245
registeredName: TestWebComponent.registeredName,
4346
componentCtor: TestWebComponent,

src/components/ThemePicker/server.ts

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
* - README.md (update theme documentation if needed)
1313
*/
1414

15+
import themeConfig from '@content/themes.json'
16+
17+
// @TODO: add tooltip that makes use of the description field
18+
19+
interface ThemeColors {
20+
backgroundOffset: string
21+
}
22+
1523
/**
1624
* Theme object interface
1725
*/
@@ -26,6 +34,8 @@ export interface Theme {
2634
category?: 'core' | 'seasonal' | 'custom'
2735
/** Boolean flag for temporary/seasonal themes */
2836
seasonal?: boolean
37+
/** Theme color settings used by head/meta scripts */
38+
colors: ThemeColors
2939
}
3040

3141
/**
@@ -39,37 +49,16 @@ export interface DefaultTheme {
3949
/**
4050
* Available themes configuration
4151
*/
42-
export const themes: Theme[] = [
43-
{
44-
id: 'light',
45-
name: 'Light',
46-
description: 'Clean light theme with blue accents',
47-
category: 'core',
48-
},
49-
{
50-
id: 'dark',
51-
name: 'Dark',
52-
description: 'Dark theme with navy background',
53-
category: 'core',
54-
},
55-
// Example of seasonal theme (uncomment and customize):
56-
// {
57-
// id: 'holiday',
58-
// name: 'Holiday',
59-
// description: 'Festive red and green theme for the holidays',
60-
// category: 'seasonal',
61-
// seasonal: true
62-
// }
63-
]
64-
65-
/**
66-
* Default theme configuration
67-
*/
68-
export const defaultTheme: DefaultTheme = {
69-
id: 'light',
70-
prefersDarkScheme: false,
52+
interface ThemeConfig {
53+
themes: Theme[]
54+
defaultTheme: DefaultTheme
7155
}
7256

57+
const themeData = themeConfig as ThemeConfig
58+
59+
export const themes = themeData.themes
60+
export const defaultTheme = themeData.defaultTheme
61+
7362
/**
7463
* Get theme by ID
7564
*/

src/content.config.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,6 @@ const testimonialCollection = defineCollection({
199199
* - The `components/Head/client.ts` to set the window.metaColors global variable that iss used to swap out the previous <meta> element when the theme is changed (`id` and `colors.backgroundOffset` properties only)
200200
*/
201201

202-
/** @NOTE: These need to be kept in sync with `src/styles/themes.css` and `src/lib/themes.ts` */
203-
const themesSchema = z.object({
204-
id: z.enum(['default', 'dark']),
205-
name: z.enum(['Light', 'Dark']),
206-
colors: z.object({
207-
backgroundOffset: z.string(),
208-
}),
209-
})
210-
211-
const themesCollection = defineCollection({
212-
loader: file('./src/content/themes.json'),
213-
schema: themesSchema,
214-
})
215-
216202
/**
217203
* Downloads
218204
*/
@@ -253,5 +239,4 @@ export const collections = {
253239
downloads: downloadsCollection,
254240
services: servicesCollection,
255241
testimonials: testimonialCollection,
256-
themes: themesCollection,
257242
}

src/content/themes.json

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
{
2-
"default": {
3-
"id": "default",
4-
"name": "Light",
5-
"colors": {
6-
"backgroundOffset": "#e2e2e2"
7-
}
2+
"defaultTheme": {
3+
"id": "light",
4+
"prefersDarkScheme": false
85
},
9-
"dark": {
10-
"id": "dark",
11-
"name": "Dark",
12-
"colors": {
13-
"backgroundOffset": "#00386d"
6+
"themes": [
7+
{
8+
"id": "light",
9+
"name": "Light",
10+
"description": "Clean light theme with blue accents",
11+
"category": "core",
12+
"colors": {
13+
"backgroundOffset": "#e2e2e2"
14+
}
15+
},
16+
{
17+
"id": "dark",
18+
"name": "Dark",
19+
"description": "Dark theme with navy background",
20+
"category": "core",
21+
"colors": {
22+
"backgroundOffset": "#00386d"
23+
}
1424
}
15-
}
25+
]
1626
}

src/pages/manifest.json.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
* Returns the web app manifest for progressive web app functionality
44
*/
55
import contactData from '@content/contact.json'
6-
import themes from '@content/themes.json'
6+
import themeConfig from '@content/themes.json'
77

88
/**
99
* GET endpoint for the web app manifest
1010
* @returns Response with manifest JSON
1111
*/
1212
export function GET() {
13-
const defaultTheme = themes.default
13+
const defaultThemeId = themeConfig.defaultTheme.id
14+
const defaultTheme =
15+
themeConfig.themes.find(theme => theme.id === defaultThemeId) || themeConfig.themes[0]
16+
17+
if (!defaultTheme) {
18+
throw new Error('No themes configured in themes.json; unable to build manifest.json')
19+
}
1420
/* eslint-disable camelcase */
1521
const manifest = {
1622
lang: 'en_US',

0 commit comments

Comments
 (0)