Skip to content

Commit

Permalink
feat: add layout header which ensure title of page is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Apr 21, 2024
1 parent e2fc922 commit 120df2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/client/pages/Layout/Header.tsx
@@ -0,0 +1,18 @@
import { useUserInfo } from '@/store/user';
import React from 'react';
import { Helmet } from 'react-helmet';

export const LayoutHeader: React.FC = React.memo(() => {
const userInfo = useUserInfo();
let title = 'Tianji - Insight into everything';
if (userInfo) {
title = userInfo.currentWorkspace.name + ' | ' + title;
}

return (
<Helmet>
<title>{title}</title>
</Helmet>
);
});
LayoutHeader.displayName = 'LayoutHeader';
3 changes: 3 additions & 0 deletions src/client/routes/__root.tsx
@@ -1,3 +1,4 @@
import { LayoutHeader } from '@/pages/Layout/Header';
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router';
// import { TanStackRouterDevtools } from '@tanstack/router-devtools';
import { Suspense } from 'react';
Expand All @@ -12,6 +13,8 @@ export const Route = createRootRouteWithContext<RouterContext>()({
return (
// https://github.com/TanStack/router/issues/857
<Suspense fallback={null}>
<LayoutHeader />

<Outlet />

{/* <TanStackRouterDevtools position="bottom-right" /> */}
Expand Down
1 change: 0 additions & 1 deletion src/client/routes/status/$slug.tsx
Expand Up @@ -3,7 +3,6 @@ import { ErrorTip } from '@/components/ErrorTip';
import { Loading } from '@/components/Loading';
import { NotFoundTip } from '@/components/NotFoundTip';
import { MonitorStatusPage } from '@/components/monitor/StatusPage';
import { Button } from '@/components/ui/button';
import { createFileRoute } from '@tanstack/react-router';

export const Route = createFileRoute('/status/$slug')({
Expand Down

0 comments on commit 120df2d

Please sign in to comment.