Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add custom title per page #2619

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.