diff --git a/components/Header.tsx b/components/Header.tsx index bfccf32..344af2e 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -1,4 +1,4 @@ -import { Container, Group, Image } from '@mantine/core' +import { Container, Group, Image, Text } from '@mantine/core' import classes from '@/styles/Header.module.css' import { pageConfig } from '@/uptime.config' import { PageConfigLink } from '@/types/config' @@ -20,25 +20,36 @@ export default function Header({ style }: { style?: React.CSSProperties }) { ) } - const links = [{ label: t('Incidents'), link: '/incidents' }, ...(pageConfig.links || [])] + const links = [ + ...(pageConfig.incidents !== false ? [{ label: t('Incidents'), link: '/incidents' }] : []), + ...(pageConfig.links || []), + ] + + const logoHref = location.pathname == '/' ? pageConfig.logoLink ?? 'https://github.com/lyc8503/UptimeFlare' : '/' return (
-
+ logo -
+ {pageConfig.showTitle && pageConfig.title && ( + + {pageConfig.title} + + )} + {links?.map(linkToElement)} diff --git a/pages/incidents.tsx b/pages/incidents.tsx index 480e5e4..2ef1736 100644 --- a/pages/incidents.tsx +++ b/pages/incidents.tsx @@ -134,7 +134,11 @@ export default function IncidentsPage({ monitors }: { monitors: MonitorTarget[] } export async function getServerSideProps() { - const { workerConfig } = await import('@/uptime.config') + const { workerConfig, pageConfig } = await import('@/uptime.config') + // If the incidents feature is disabled, don't expose this page + if (pageConfig.incidents === false) { + return { redirect: { destination: '/', permanent: false } } + } // Only present these values to client const monitors: MonitorTarget[] = workerConfig.monitors.map((monitor) => ({ id: monitor.id, diff --git a/pages/index.tsx b/pages/index.tsx index 8af1e64..ec61fa1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -79,11 +79,11 @@ export async function getServerSideProps() { id: monitor.id, name: monitor.name, // @ts-ignore - tooltip: monitor?.tooltip, + tooltip: monitor?.tooltip ?? null, // @ts-ignore - statusPageLink: monitor?.statusPageLink, + statusPageLink: monitor?.statusPageLink ?? null, // @ts-ignore - hideLatencyChart: monitor?.hideLatencyChart, + hideLatencyChart: monitor?.hideLatencyChart ?? null, } }) diff --git a/types/config.ts b/types/config.ts index d6fc04c..1ef4603 100644 --- a/types/config.ts +++ b/types/config.ts @@ -6,6 +6,9 @@ export type PageConfig = { group?: PageConfigGroup favicon?: string logo?: string + logoLink?: string + showTitle?: boolean + incidents?: boolean maintenances?: { upcomingColor?: string } diff --git a/uptime.config.full.ts b/uptime.config.full.ts index e402ba7..5be0c16 100644 --- a/uptime.config.full.ts +++ b/uptime.config.full.ts @@ -20,6 +20,14 @@ const pageConfig: PageConfig = { // favicon: 'https://example.com/favicon.ico', // [OPTIONAL] Set the path to your logo, default to '/logo.svg' if not specified // logo: 'https://example.com/logo.svg', + // [OPTIONAL] Custom link opened when clicking the header logo (from the home page), + // default to 'https://github.com/lyc8503/UptimeFlare' if not specified + // logoLink: 'https://example.com', + // [OPTIONAL] Show the `title` text next to the logo in the header, default to false + // showTitle: true, + // [OPTIONAL] Set to false to disable the incidents feature entirely + // (hides the "Incidents" header tab and makes the /incidents page redirect home), default to true + // incidents: false, // [OPTIONAL] Maintenance related settings maintenances: { // [OPTIONAL] The color of upcoming maintenance alerts, default to 'gray' diff --git a/worker/src/store.ts b/worker/src/store.ts index f0a2186..3e51ae7 100644 --- a/worker/src/store.ts +++ b/worker/src/store.ts @@ -7,6 +7,8 @@ import { } from '../../types/config' export async function getFromStore(env: Env, key: string): Promise { + // No D1 binding outside the Cloudflare runtime (e.g. plain `next dev`); return empty state instead of throwing + if (!env?.UPTIMEFLARE_D1) return null const stmt = env.UPTIMEFLARE_D1.prepare('SELECT value FROM uptimeflare WHERE key = ?') const result = await stmt.bind(key).first<{ value: string }>() return result?.value || null