File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,16 +7,17 @@ export function createTitle(title) {
77 // Titles for various content areas
88 let suffix = '' ;
99 switch ( true ) {
10- // Shouldn't be an issue, but `startsWith` is wildly faster than `includes`
1110 case url . startsWith ( '/guide/v11' ) :
12- case url . startsWith ( '/guide/v10' ) :
1311 suffix = 'Preact Guide' ;
1412 break ;
15- case url . startsWith ( '/tutorial ' ) :
16- suffix = 'Preact Tutorial ' ;
13+ case url . startsWith ( '/guide/v10 ' ) :
14+ suffix = 'Preact Guide v10 ' ;
1715 break ;
1816 case url . startsWith ( '/guide/v8' ) :
19- suffix = 'Preact Version 8' ;
17+ suffix = 'Preact Guide v8' ;
18+ break ;
19+ case url . startsWith ( '/tutorial' ) :
20+ suffix = 'Preact Tutorial' ;
2021 break ;
2122 default :
2223 suffix = 'Preact' ;
Original file line number Diff line number Diff line change 11import { useEffect } from 'preact/hooks' ;
2+ import { useLocation } from 'preact-iso' ;
23
34import { createTitle } from './page-title' ;
45import { getContent } from './content.js' ;
@@ -59,14 +60,17 @@ export function prefetchContent(path) {
5960 * @param {string } title
6061 */
6162export function useTitle ( title ) {
63+ const { url } = useLocation ( ) ;
64+
6265 if ( typeof window === 'undefined' ) {
6366 globalThis . title = createTitle ( title ) ;
6467 }
68+
6569 useEffect ( ( ) => {
6670 if ( title ) {
6771 document . title = createTitle ( title ) ;
6872 }
69- } , [ title ] ) ;
73+ } , [ title , url ] ) ;
7074}
7175
7276/**
You can’t perform that action at this time.
0 commit comments