feat: support website title

This commit is contained in:
diced
2025-01-10 12:07:53 -08:00
parent 4a2988914a
commit 863d68695f
18 changed files with 71 additions and 12 deletions

View File

@@ -29,13 +29,19 @@ const fetcher = async (url: RequestInfo | URL) => {
return res.json();
};
export default function App({ Component, pageProps }: AppProps) {
export default function App({
Component,
pageProps,
}: AppProps & { Component: AppProps['Component'] & { title: string } }) {
const themes: ZiplineTheme[] = pageProps.themes;
return (
<>
<Head>
<title>Zipline</title>
<title>
{pageProps?.config?.website?.title ?? 'Zipline'}
{Component.title ? ` ${Component.title}` : ''}
</title>
<meta name='viewport' content='minimum-scale=1, initial-scale=1, width=device-width' />
<link rel='manifest' href='/manifest.json' />
<link rel='icon' type='image/png' href='/favicon' />

View File

@@ -350,3 +350,5 @@ export const getServerSideProps = withSafeConfig(async () => {
return {};
});
Login.title = 'Login';

View File

@@ -4,7 +4,7 @@ import { useRouter } from 'next/router';
import { useEffect } from 'react';
import { mutate } from 'swr';
export default function Login() {
export default function Logout() {
const router = useRouter();
const setUser = useUserStore((state) => state.setUser);
@@ -31,3 +31,5 @@ export default function Login() {
</>
);
}
Logout.title = 'Logout';

View File

@@ -199,3 +199,5 @@ export const getServerSideProps = withSafeConfig<{
invite: invite as unknown as Invite,
};
});
Register.title = 'Register';

View File

@@ -4,7 +4,7 @@ import { Container } from '@mantine/core';
import { readFile } from 'fs/promises';
import { InferGetServerSidePropsType } from 'next';
export default function Login({ tos }: InferGetServerSidePropsType<typeof getServerSideProps>) {
export default function TermsOfService({ tos }: InferGetServerSidePropsType<typeof getServerSideProps>) {
return (
<Container my='md'>
<Markdown md={tos!} />
@@ -18,9 +18,17 @@ export const getServerSideProps = withSafeConfig(async (_, config) => {
notFound: true,
};
const file = await readFile(config.website.tos, 'utf8');
try {
const file = await readFile(config.website.tos, 'utf8');
return {
tos: file,
};
return {
tos: file,
};
} catch {
return {
notFound: true,
};
}
});
TermsOfService.title = 'Terms of Service';

View File

@@ -48,3 +48,5 @@ export const getServerSideProps = withSafeConfig(async (ctx) => {
return {};
});
DashboardAdminInvites.title = 'Invites';

View File

@@ -47,3 +47,5 @@ export const getServerSideProps = withSafeConfig(async (ctx) => {
return {};
});
DashboardAdminSettings.title = 'Server Settings';

View File

@@ -8,6 +8,7 @@ import { canInteract } from '@/lib/role';
import { getSession } from '@/server/session';
import { LoadingOverlay } from '@mantine/core';
import { InferGetServerSidePropsType } from 'next';
import Head from 'next/head';
export default function DashboardAdminUsersId({
user,
@@ -18,9 +19,16 @@ export default function DashboardAdminUsersId({
if (!user) return null;
return (
<Layout config={config}>
<ViewFiles user={user} />
</Layout>
<>
<Head>
<title>
{config.website.title ?? 'Zipline'} {user.username}&quot;s files
</title>
</Head>
<Layout config={config}>
<ViewFiles user={user} />
</Layout>
</>
);
}

View File

@@ -48,3 +48,5 @@ export const getServerSideProps = withSafeConfig(async (ctx) => {
return {};
});
DashboardAdminUsers.title = 'Users';

View File

@@ -19,3 +19,5 @@ export default function DashboardFilesPage({
}
export const getServerSideProps = withSafeConfig();
DashboardFilesPage.title = 'Files';

View File

@@ -19,3 +19,5 @@ export default function DashboardFoldersPage({
}
export const getServerSideProps = withSafeConfig();
DashboardFoldersPage.title = 'Folders';

View File

@@ -28,3 +28,5 @@ export default function DashboardMetricsPage({
}
export const getServerSideProps = withSafeConfig();
DashboardMetricsPage.title = 'Metrics';

View File

@@ -19,3 +19,5 @@ export default function DashboardUserSettings({
}
export const getServerSideProps = withSafeConfig();
DashboardUserSettings.title = 'Settings';

View File

@@ -32,3 +32,5 @@ export default function DashboardUploadFile({
}
export const getServerSideProps = withSafeConfig();
DashboardUploadFile.title = 'Upload';

View File

@@ -47,3 +47,5 @@ export const getServerSideProps = withSafeConfig<{
codeMeta,
};
});
DashboardUploadText.title = 'Upload Text';

View File

@@ -19,3 +19,5 @@ export default function DashboardUrlsPage({
}
export const getServerSideProps = withSafeConfig();
DashboardUrlsPage.title = 'URLs';

View File

@@ -5,12 +5,21 @@ import { Folder, cleanFolder } from '@/lib/db/models/folder';
import { withSafeConfig } from '@/lib/middleware/next/withSafeConfig';
import { Container, SimpleGrid, Title } from '@mantine/core';
import { InferGetServerSidePropsType } from 'next';
import Head from 'next/head';
export default function ViewFolderId({ folder }: InferGetServerSidePropsType<typeof getServerSideProps>) {
export default function ViewFolderId({
folder,
config,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
if (!folder) return null;
return (
<>
<Head>
<title>
{config.website.title ?? 'Zipline'} {folder.name}
</title>
</Head>
<Container>
<Title order={1}>{folder.name}</Title>

View File

@@ -245,3 +245,5 @@ export const getServerSideProps: GetServerSideProps = async () => {
props: {},
};
};
Setup.title = 'Setup';