File tree Expand file tree Collapse file tree 4 files changed +29
-15
lines changed Expand file tree Collapse file tree 4 files changed +29
-15
lines changed Original file line number Diff line number Diff line change 1+ import { createMetadata } from '@/lib/metadata' ;
12import { useTranslations } from 'next-intl' ;
23import Link from 'next/link' ;
34
@@ -119,3 +120,9 @@ export default function HomePage() {
119120 </ main >
120121 ) ;
121122}
123+
124+ export async function generateMetadata ( ) {
125+ return createMetadata ( {
126+ pathname : '/' ,
127+ } ) ;
128+ }
Original file line number Diff line number Diff line change 1- import { NextIntlClientProvider , hasLocale } from 'next-intl' ;
1+ import { NextIntlClientProvider } from 'next-intl' ;
22import './global.css' ;
33import { Provider } from '@/app/provider' ;
44
@@ -11,7 +11,6 @@ import { getLangDir } from 'rtl-detect';
1111
1212export async function generateMetadata ( ) {
1313 const t = await getTranslations ( 'meta' ) ;
14-
1514 return createMetadata ( {
1615 title : {
1716 template : `%s | ${ t ( 'title' ) } ` ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import * as icons from '@/mdx/Icon';
77import { loader } from 'fumadocs-core/source' ;
88import { createMDXSource } from 'fumadocs-mdx' ;
99import { createElement } from 'react' ;
10+ import { getDocUrl } from './utils' ;
1011
1112// See https://fumadocs.dev//docs/headless/source-api for more info
1213export const docs = loader ( {
@@ -18,14 +19,7 @@ export const docs = loader({
1819 return createElement ( icons [ icon as keyof typeof icons ] ) ;
1920 } ,
2021 url ( slugs ) {
21- // remove \d\d- from slug
22- const url = `/docs/${ slugs
23- . map ( ( slug ) => {
24- return slug . replace ( / ^ \d \d - / , '' ) ;
25- } )
26- . join ( '/' ) } `;
27-
28- return url ;
22+ return getDocUrl ( slugs ) ;
2923 } ,
3024 // https://fumadocs.dev/docs/headless/source-api#page-tree-1
3125 pageTree : {
Original file line number Diff line number Diff line change @@ -124,12 +124,26 @@ export const parseDocId = (id: string) => {
124124 whereTag,
125125 } ;
126126} ;
127-
128- export function getDocUrl ( slug : string [ ] | string | undefined ) {
129- if ( typeof slug === 'string' ) {
130- return `/docs/${ slug } ` ;
127+ export function removeTrailingSlash ( url : string ) {
128+ return url . endsWith ( '/' ) ? url . slice ( 0 , - 1 ) : url ;
129+ }
130+ export function removeLeadingSlash ( url : string ) {
131+ return url . startsWith ( '/' ) ? url . slice ( 1 ) : url ;
132+ }
133+ export function getDocUrl ( slugs : string [ ] | string | undefined ) {
134+ if ( ! slugs || slugs === '/' ) {
135+ return '/docs' ;
136+ }
137+ if ( typeof slugs === 'string' ) {
138+ return removeTrailingSlash ( `/docs/${ removeLeadingSlash ( slugs ) } ` ) ;
131139 }
132- return `/docs/${ ( slug || [ ] ) . join ( '/' ) } ` ;
140+ return removeTrailingSlash (
141+ `/docs/${ (
142+ slugs . map ( ( slug ) => {
143+ return slug . replace ( / ^ \d \d - / , '' ) ;
144+ } )
145+ ) . join ( '/' ) } `,
146+ ) ;
133147}
134148
135149export function getLearnUrl ( slug : string [ ] | string | undefined ) {
You can’t perform that action at this time.
0 commit comments