mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 15:16:28 +08:00
27 lines
713 B
TypeScript
27 lines
713 B
TypeScript
import type { NextRouter } from 'next/router';
|
|
import { useMemo } from 'react';
|
|
|
|
import { WorkspaceSubPathName } from '../shared';
|
|
|
|
export function useRouterTitle(router: NextRouter) {
|
|
return useMemo(() => {
|
|
if (!router.isReady) {
|
|
return 'Loading...';
|
|
} else {
|
|
if (
|
|
!router.query.pageId &&
|
|
router.pathname.startsWith('/workspace/[workspaceId]/')
|
|
) {
|
|
const subPath = router.pathname.split('/').at(-1);
|
|
if (subPath && subPath in WorkspaceSubPathName) {
|
|
return (
|
|
WorkspaceSubPathName[subPath as keyof typeof WorkspaceSubPathName] +
|
|
' - AFFiNE'
|
|
);
|
|
}
|
|
}
|
|
return 'AFFiNE';
|
|
}
|
|
}, [router]);
|
|
}
|