Skip to content

Commit 488cde5

Browse files
feat(layout.tsx): added Dynamic Title (#230)
1 parent 45cb65c commit 488cde5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

apps/website/src/routes/docs/layout.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { component$, Slot, useContext } from '@builder.io/qwik';
2+
import { DocumentHead } from '@builder.io/qwik-city';
23
import { MaterialProvider } from '../../components/material';
34
import { Menu } from '../../components/menu/menu';
45
import { APP_STATE } from '../../constants';
@@ -27,3 +28,19 @@ export default component$(() => {
2728
</>
2829
);
2930
});
31+
32+
export const head: DocumentHead = ({ url }) => {
33+
const UrlPathList = url.pathname.split('/').filter((path) => path !== '');
34+
if (UrlPathList.length === 3) {
35+
const Component =
36+
UrlPathList[2].charAt(0).toUpperCase() + UrlPathList[2].slice(1);
37+
const ComponentTheme =
38+
UrlPathList[1].charAt(0).toUpperCase() + UrlPathList[1].slice(1);
39+
return {
40+
title: `${Component} | ${ComponentTheme} | QwikUI`,
41+
};
42+
}
43+
return {
44+
title: `Docs | QwikUI`,
45+
};
46+
};

0 commit comments

Comments
 (0)