Skip to content

Commit

Permalink
docs: add custom title per page
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-mesnil committed Nov 21, 2024
1 parent fe9d5fb commit 6622d4f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions website/app/components/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ type LayoutProps = {
}
}

export async function generateMetadata({ params }: { params: { [key: string]: string } }) {
const { id } = params
const { data } = getPageContent(`${getRepository(id)}/docs/index.mdx`, true)
const title = data?.title
const description = data?.description

return {
title: `Welcome UI - ${title}`,
description: description,
}
}

const Layout = ({ children, params }: LayoutProps) => {
const pages = getPages()
const { id } = params
Expand Down
5 changes: 5 additions & 0 deletions website/app/components/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import { Flex } from '@welcome-ui/flex'
import { Grid } from '@welcome-ui/grid'
import { Text } from '@welcome-ui/text'
import { Box } from '@welcome-ui/box'
import { Metadata } from 'next'

import { getPages } from '@/build-app/utils/pages-components'
import { getName, getRepository } from '@/build-app/utils/transform-name'
import { getPageContent } from '@/build-app/utils/page-content'

export const metadata: Metadata = {
title: 'Welcome UI - Components',
}

const Page = () => {
const pages = getPages()

Expand Down
10 changes: 10 additions & 0 deletions website/app/foundations/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ import { TableOfContent } from '@/build-app/components/TableOfContent'
import { getPageContent } from '@/build-app/utils/page-content'
import { getPages, getStaticParams } from '@/build-app/utils/pages-exports'
import { PrevNextPage } from '@/build-app/components/PrevNextPage'
import { getName } from '@/build-app/utils/transform-name'

type PageProps = {
params: {
id: string
}
}

export async function generateMetadata({ params }: { params: { [key: string]: string } }) {
const { id } = params
const title = getName(id)

return {
title: `Welcome UI - ${title}`,
}
}

export async function generateStaticParams() {
const pages = getPages('foundations')

Expand Down
2 changes: 1 addition & 1 deletion website/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang="en">
<head>
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<link href="/favicon.png" rel="icon" type="image/png" />
</head>
<body>
<StyledComponentsRegistry>
Expand Down
Binary file removed website/public/favicon.ico
Binary file not shown.
Binary file added website/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/public/og-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6622d4f

Please sign in to comment.