File tree Expand file tree Collapse file tree 4 files changed +46
-3
lines changed
Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,17 @@ import { I18nProvider } from "~/i18n/i18n-context";
77import { Title } from "@solidjs/meta" ;
88import { useThemeListener } from "@kobalte/solidbase/client" ;
99import { usePace } from "@kobalte/solidbase/default-theme/pace.js" ;
10+ import { useProjectTitle } from "~/ui/use-project-title" ;
1011
1112export default function ( props : RouteSectionProps ) {
1213 useThemeListener ( ) ;
1314 usePace ( ) ;
1415
16+ const projectTitle = useProjectTitle ( ) ;
17+
1518 return (
1619 < I18nProvider >
17- < Title > Solid Docs </ Title >
20+ < Title > { projectTitle ( ) } </ Title >
1821 < ErrorBoundary fallback = { ( ) => < NotFound /> } >
1922 < Layout > { props . children } </ Layout >
2023 </ ErrorBoundary >
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { coreEntries } from "solid:collection";
55import { Pagination } from "~/ui/pagination" ;
66import { EditPageLink } from "./edit-page-link" ;
77import { PageIssueLink } from "./page-issue-link" ;
8+ import { useProjectTitle } from "./use-project-title" ;
89
910interface DocsLayoutProps {
1011 entries : typeof coreEntries ;
@@ -13,6 +14,7 @@ interface DocsLayoutProps {
1314
1415export const DocsLayout = ( props : DocsLayoutProps ) => {
1516 const location = useLocation ( ) ;
17+ const projectTitle = useProjectTitle ( ) ;
1618
1719 const collection = ( ) =>
1820 location . pathname . includes ( "/reference/" )
@@ -40,7 +42,7 @@ export const DocsLayout = (props: DocsLayoutProps) => {
4042 < Show when = { props . entries } keyed >
4143 < >
4244 < Show when = { titles ( ) ?. title } fallback = { < Title > SolidDocs</ Title > } >
43- { ( title ) => < Title > { `${ title ( ) } - SolidDocs ` } </ Title > }
45+ { ( title ) => < Title > { `${ title ( ) } - ${ projectTitle ( ) } ` } </ Title > }
4446 </ Show >
4547 < div id = "rr" class = "flex relative justify-center" >
4648 < article class = "w-fit overflow-hidden pb-16 lg:px-5 expressive-code-overrides lg:max-w-none" >
Original file line number Diff line number Diff line change @@ -2,11 +2,14 @@ import { Title } from "@solidjs/meta";
22import { Layout } from "./layout" ;
33import { HttpStatusCode } from "@solidjs/start" ;
44import { A } from "~/ui/i18n-anchor" ;
5+ import { useProjectTitle } from "./use-project-title" ;
56
67export function NotFound ( ) {
8+ const projectTitle = useProjectTitle ( ) ;
9+
710 return (
811 < >
9- < Title > 404 - SolidDocs </ Title >
12+ < Title > Not Found - { projectTitle ( ) } </ Title >
1013 < Layout isError >
1114 < HttpStatusCode code = { 404 } />
1215 < div class = "flex flex-col items-center" >
Original file line number Diff line number Diff line change 1+ import { type Accessor , createEffect , createSignal } from "solid-js" ;
2+ import { useMatch } from "@solidjs/router" ;
3+
4+ const SOLID_START_TITLE = "SolidStart Docs" ;
5+ const SOLID_ROUTER_TITLE = "Solid Router Docs" ;
6+ const SOLID_META_TITLE = "Solid Meta Docs" ;
7+ const SOLID_TITLE = "Solid Docs" ;
8+
9+ type ProjectTitle =
10+ | typeof SOLID_START_TITLE
11+ | typeof SOLID_ROUTER_TITLE
12+ | typeof SOLID_META_TITLE
13+ | typeof SOLID_TITLE ;
14+
15+ export function useProjectTitle ( ) : Accessor < ProjectTitle > {
16+ const [ title , setTitle ] = createSignal < ProjectTitle > ( SOLID_TITLE ) ;
17+
18+ const isStart = useMatch ( ( ) => "/solid-start/*" ) ;
19+ const isRouter = useMatch ( ( ) => "/solid-router/*" ) ;
20+ const isMeta = useMatch ( ( ) => "/solid-meta/*" ) ;
21+
22+ createEffect ( ( ) => {
23+ if ( isStart ( ) ) {
24+ setTitle ( SOLID_START_TITLE ) ;
25+ } else if ( isRouter ( ) ) {
26+ setTitle ( SOLID_ROUTER_TITLE ) ;
27+ } else if ( isMeta ( ) ) {
28+ setTitle ( SOLID_META_TITLE ) ;
29+ } else {
30+ setTitle ( SOLID_TITLE ) ;
31+ }
32+ } ) ;
33+
34+ return title ;
35+ }
You can’t perform that action at this time.
0 commit comments