fix: add page titles (#883)

This commit is contained in:
Peng Xiao 2023-02-09 11:30:57 +08:00 committed by GitHub
parent 0ccaf2bc45
commit 0984c37cad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 2 deletions

View File

@ -59,7 +59,6 @@ export const Editor = ({ page, workspace, setEditor }: Props) => {
}
setEditor(editor);
document.title = page.meta.title || 'Untitled';
return ret;
}, [workspace, page, setEditor]);

View File

@ -1,5 +1,13 @@
import NotfoundPage from '@/components/404';
import Head from 'next/head';
export default function Custom404() {
return <NotfoundPage></NotfoundPage>;
return (
<>
<Head>
<title>404 - AFFiNE</title>
</Head>
<NotfoundPage></NotfoundPage>
</>
);
}

View File

@ -50,6 +50,7 @@ const App = ({ Component, pageProps }: AppPropsWithLayout) => {
sizes="180x180"
href="/icons/apple-touch-icon.png"
/>
<title>AFFiNE</title>
</Head>
<Logger />
<ProviderComposer

View File

@ -15,6 +15,8 @@ import { useRouter } from 'next/router';
import { usePageHelper } from '@/hooks/use-page-helper';
import dynamic from 'next/dynamic';
import { EditorContainer } from '@blocksuite/editor';
import Head from 'next/head';
import { useTranslation } from '@affine/i18n';
const DynamicBlocksuite = dynamic(() => import('@/components/editor'), {
ssr: false,
});
@ -25,8 +27,12 @@ const Page: NextPageWithLayout = () => {
(editor: EditorContainer) => setEditor.current(editor),
[setEditor]
);
const { t } = useTranslation();
return (
<>
<Head>
<title>{currentPage?.meta?.title || t('Untitled')} - AFFiNE</title>
</Head>
<EditorHeader />
<MobileModal />

View File

@ -5,6 +5,8 @@ import { ReactElement } from 'react';
import WorkspaceLayout from '@/components/workspace-layout';
import { useTranslation } from '@affine/i18n';
import { PageMeta, useAppState } from '@/providers/app-state-provider';
import Head from 'next/head';
const All = () => {
const { currentWorkspace } = useAppState();
const pageList = (currentWorkspace?.blocksuiteWorkspace?.meta.pageMetas ||
@ -12,6 +14,9 @@ const All = () => {
const { t } = useTranslation();
return (
<>
<Head>
<title>{t('All pages')} - AFFiNE</title>
</Head>
<PageListHeader icon={<AllPagesIcon />}>{t('All pages')}</PageListHeader>
<PageList
pageList={pageList.filter(p => !p.trash)}

View File

@ -5,11 +5,15 @@ import { ReactElement } from 'react';
import WorkspaceLayout from '@/components/workspace-layout';
import { useTranslation } from '@affine/i18n';
import { useAppState } from '@/providers/app-state-provider';
import Head from 'next/head';
export const Favorite = () => {
const { pageList } = useAppState();
const { t } = useTranslation();
return (
<>
<Head>
<title>{t('Favourites')} - AFFiNE</title>
</Head>
<PageListHeader icon={<FavouritesIcon />}>
{t('Favourites')}
</PageListHeader>

View File

@ -19,6 +19,7 @@ import WorkspaceLayout from '@/components/workspace-layout';
import { WorkspaceUnit } from '@affine/datacenter';
import { useTranslation } from '@affine/i18n';
import { PageListHeader } from '@/components/header';
import Head from 'next/head';
const useTabMap = () => {
const { t } = useTranslation();
@ -79,6 +80,9 @@ const WorkspaceSetting = () => {
useTabMap();
return (
<>
<Head>
<title>{t('Settings')} - AFFiNE</title>
</Head>
<StyledSettingContainer>
<PageListHeader icon={<SettingsIcon />}>{t('Settings')}</PageListHeader>
<StyledSettingSidebar>

View File

@ -5,11 +5,15 @@ import { ReactElement } from 'react';
import WorkspaceLayout from '@/components/workspace-layout';
import { useTranslation } from '@affine/i18n';
import { useAppState } from '@/providers/app-state-provider';
import Head from 'next/head';
export const Trash = () => {
const { pageList } = useAppState();
const { t } = useTranslation();
return (
<>
<Head>
<title>{t('Trash')} - AFFiNE</title>
</Head>
<PageListHeader icon={<TrashIcon />}>{t('Trash')}</PageListHeader>
<PageList
pageList={pageList.filter(p => p.trash)}