refactor: update website configuration structure to use 'ui' instead of 'metadata' for theme and mode settings
This commit is contained in:
parent
4bad9714fa
commit
7cc1fd5835
@ -29,7 +29,7 @@ interface ProvidersProps {
|
|||||||
*/
|
*/
|
||||||
export function Providers({ children, locale }: ProvidersProps) {
|
export function Providers({ children, locale }: ProvidersProps) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const defaultMode = websiteConfig.metadata.mode?.defaultMode ?? 'system';
|
const defaultMode = websiteConfig.ui.mode?.defaultMode ?? 'system';
|
||||||
|
|
||||||
// available languages that will be displayed in the docs UI
|
// available languages that will be displayed in the docs UI
|
||||||
// make sure `locale` is consistent with your i18n config
|
// make sure `locale` is consistent with your i18n config
|
||||||
|
@ -71,7 +71,7 @@ export function SidebarUser({ user, className }: SidebarUserProps) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const showModeSwitch = websiteConfig.metadata.mode?.enableSwitch ?? false;
|
const showModeSwitch = websiteConfig.ui.mode?.enableSwitch ?? false;
|
||||||
const showLocaleSwitch = LOCALES.length > 1;
|
const showLocaleSwitch = LOCALES.length > 1;
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
|
|
||||||
const COOKIE_NAME = 'active_theme';
|
const COOKIE_NAME = 'active_theme';
|
||||||
const DEFAULT_THEME = websiteConfig.metadata.theme?.defaultTheme ?? 'default';
|
const DEFAULT_THEME = websiteConfig.ui.theme?.defaultTheme ?? 'default';
|
||||||
|
|
||||||
function setThemeCookie(theme: string) {
|
function setThemeCookie(theme: string) {
|
||||||
if (typeof window === 'undefined') return;
|
if (typeof window === 'undefined') return;
|
||||||
|
@ -12,7 +12,7 @@ import { useEffect, useState } from 'react';
|
|||||||
* Mode switcher component, used in the footer
|
* Mode switcher component, used in the footer
|
||||||
*/
|
*/
|
||||||
export function ModeSwitcherHorizontal() {
|
export function ModeSwitcherHorizontal() {
|
||||||
if (!websiteConfig.metadata.mode?.enableSwitch) {
|
if (!websiteConfig.ui.mode?.enableSwitch) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import { useTheme } from 'next-themes';
|
|||||||
* Mode switcher component, used in the navbar
|
* Mode switcher component, used in the navbar
|
||||||
*/
|
*/
|
||||||
export function ModeSwitcher() {
|
export function ModeSwitcher() {
|
||||||
if (!websiteConfig.metadata.mode?.enableSwitch) {
|
if (!websiteConfig.ui.mode?.enableSwitch) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import { useThemeConfig } from './active-theme-provider';
|
|||||||
* https://github.com/TheOrcDev/orcish-dashboard/blob/main/components/theme-selector.tsx
|
* https://github.com/TheOrcDev/orcish-dashboard/blob/main/components/theme-selector.tsx
|
||||||
*/
|
*/
|
||||||
export function ThemeSelector() {
|
export function ThemeSelector() {
|
||||||
if (!websiteConfig.metadata.theme?.enableSwitch) {
|
if (!websiteConfig.ui.theme?.enableSwitch) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import type { WebsiteConfig } from '@/types';
|
|||||||
* https://mksaas.com/docs/config/website
|
* https://mksaas.com/docs/config/website
|
||||||
*/
|
*/
|
||||||
export const websiteConfig: WebsiteConfig = {
|
export const websiteConfig: WebsiteConfig = {
|
||||||
metadata: {
|
ui: {
|
||||||
theme: {
|
theme: {
|
||||||
defaultTheme: 'default',
|
defaultTheme: 'default',
|
||||||
enableSwitch: true,
|
enableSwitch: true,
|
||||||
@ -17,6 +17,8 @@ export const websiteConfig: WebsiteConfig = {
|
|||||||
defaultMode: 'dark',
|
defaultMode: 'dark',
|
||||||
enableSwitch: true,
|
enableSwitch: true,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
metadata: {
|
||||||
images: {
|
images: {
|
||||||
ogImage: '/og.png',
|
ogImage: '/og.png',
|
||||||
logoLight: '/logo.png',
|
logoLight: '/logo.png',
|
||||||
|
11
src/types/index.d.ts
vendored
11
src/types/index.d.ts
vendored
@ -6,6 +6,7 @@ import type { CreditPackage } from '@/credits/types';
|
|||||||
* website config, without translations
|
* website config, without translations
|
||||||
*/
|
*/
|
||||||
export type WebsiteConfig = {
|
export type WebsiteConfig = {
|
||||||
|
ui: UiConfig;
|
||||||
metadata: MetadataConfig;
|
metadata: MetadataConfig;
|
||||||
features: FeaturesConfig;
|
features: FeaturesConfig;
|
||||||
routes: RoutesConfig;
|
routes: RoutesConfig;
|
||||||
@ -22,12 +23,18 @@ export type WebsiteConfig = {
|
|||||||
credits: CreditsConfig;
|
credits: CreditsConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI configuration
|
||||||
|
*/
|
||||||
|
export interface UiConfig {
|
||||||
|
mode?: ModeConfig;
|
||||||
|
theme?: ThemeConfig;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Website metadata
|
* Website metadata
|
||||||
*/
|
*/
|
||||||
export interface MetadataConfig {
|
export interface MetadataConfig {
|
||||||
mode?: ModeConfig;
|
|
||||||
theme?: ThemeConfig;
|
|
||||||
images?: ImagesConfig;
|
images?: ImagesConfig;
|
||||||
social?: SocialConfig;
|
social?: SocialConfig;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user