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 d141935
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 8 deletions.
13 changes: 6 additions & 7 deletions website/app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { Text } from '@welcome-ui/text'
import { Button } from '@welcome-ui/button'
import { Box } from '@welcome-ui/box'
import styled, { th } from '@xstyled/styled-components'
import { Link } from '@welcome-ui/link'
import { Card } from '@welcome-ui/card'
import { Stack } from '@welcome-ui/stack'
Expand Down Expand Up @@ -62,10 +61,10 @@ const posts = [
},
]

const Title = styled(Link)`
${th('texts.h5')};
display: inline !important;
`
// const Title = styled(Link)`
// ${th('texts.h5')};
// display: inline !important;
// `

const Home = () => {
return (
Expand All @@ -90,9 +89,9 @@ const Home = () => {
</Tag>
))}
</Stack>
<Title href={link} rel="noopener nofollow" target="_blank">
<Link href={link} rel="noopener nofollow" target="_blank">
{title}
</Title>
</Link>
<Box alignItems={{ md: 'flex-end' }} display={{ md: 'flex' }}>
<Flex direction="column" gap="md">
<Text mt="md">{description}</Text>
Expand Down
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 d141935

Please sign in to comment.