♻️ Improved code structure for layout, remove most settings components
This commit is contained in:
31
src/components/layout/Meta/BoardHead.tsx
Normal file
31
src/components/layout/Meta/BoardHead.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import Head from 'next/head';
|
||||
import React from 'react';
|
||||
|
||||
import { useConfigContext } from '../../../config/provider';
|
||||
|
||||
export const BoardHeadOverride = () => {
|
||||
const { config } = useConfigContext();
|
||||
|
||||
if (!config) return null;
|
||||
|
||||
const { metaTitle, faviconUrl } = config.settings.customization;
|
||||
|
||||
return (
|
||||
<Head>
|
||||
{metaTitle && metaTitle.length > 0 && (
|
||||
<>
|
||||
<title>{metaTitle}</title>
|
||||
<meta name="apple-mobile-web-app-title" content={metaTitle} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{faviconUrl && faviconUrl.length > 0 && (
|
||||
<>
|
||||
<link rel="shortcut icon" href={faviconUrl} />
|
||||
|
||||
<link rel="apple-touch-icon" href={faviconUrl} />
|
||||
</>
|
||||
)}
|
||||
</Head>
|
||||
);
|
||||
};
|
||||
26
src/components/layout/Meta/CommonHead.tsx
Normal file
26
src/components/layout/Meta/CommonHead.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { useMantineTheme } from '@mantine/core';
|
||||
import Head from 'next/head';
|
||||
|
||||
export const CommonHead = () => {
|
||||
const { colorScheme } = useMantineTheme();
|
||||
|
||||
return (
|
||||
<Head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
||||
<link rel="shortcut icon" href="/imgs/favicon/favicon.svg" />
|
||||
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
|
||||
{/* configure apple splash screen & touch icon */}
|
||||
<link rel="apple-touch-icon" href="/imgs/favicon/favicon.svg" />
|
||||
<meta name="apple-mobile-web-app-title" content="Homarr" />
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
|
||||
<meta
|
||||
name="apple-mobile-web-app-status-bar-style"
|
||||
content={colorScheme === 'dark' ? 'white-translucent' : 'black-translucent'}
|
||||
/>
|
||||
</Head>
|
||||
);
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
/* eslint-disable react/no-invalid-html-attribute */
|
||||
import NextHead from 'next/head';
|
||||
import React from 'react';
|
||||
|
||||
import { useConfigContext } from '../../../config/provider';
|
||||
import { SafariStatusBarStyle } from './SafariStatusBarStyle';
|
||||
|
||||
export function Head() {
|
||||
const { config } = useConfigContext();
|
||||
|
||||
return (
|
||||
<NextHead>
|
||||
<title>{config?.settings.customization.metaTitle || 'Homarr 🦞'}</title>
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href={config?.settings.customization.faviconUrl || '/imgs/favicon/favicon.svg'}
|
||||
/>
|
||||
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
|
||||
{/* configure apple splash screen & touch icon */}
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
href={config?.settings.customization.faviconUrl || '/imgs/favicon/favicon.svg'}
|
||||
/>
|
||||
<meta
|
||||
name="apple-mobile-web-app-title"
|
||||
content={config?.settings.customization.metaTitle || 'Homarr'}
|
||||
/>
|
||||
|
||||
<SafariStatusBarStyle />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
</NextHead>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { useMantineTheme } from '@mantine/core';
|
||||
|
||||
export const SafariStatusBarStyle = () => {
|
||||
const { colorScheme } = useMantineTheme();
|
||||
const isDark = colorScheme === 'dark';
|
||||
return (
|
||||
<meta
|
||||
name="apple-mobile-web-app-status-bar-style"
|
||||
content={isDark ? 'white-translucent' : 'black-translucent'}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user