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' ;
1
2
import { useTranslations } from 'next-intl' ;
2
3
import Link from 'next/link' ;
3
4
@@ -119,3 +120,9 @@ export default function HomePage() {
119
120
</ main >
120
121
) ;
121
122
}
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' ;
2
2
import './global.css' ;
3
3
import { Provider } from '@/app/provider' ;
4
4
@@ -11,7 +11,6 @@ import { getLangDir } from 'rtl-detect';
11
11
12
12
export async function generateMetadata ( ) {
13
13
const t = await getTranslations ( 'meta' ) ;
14
-
15
14
return createMetadata ( {
16
15
title : {
17
16
template : `%s | ${ t ( 'title' ) } ` ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import * as icons from '@/mdx/Icon';
7
7
import { loader } from 'fumadocs-core/source' ;
8
8
import { createMDXSource } from 'fumadocs-mdx' ;
9
9
import { createElement } from 'react' ;
10
+ import { getDocUrl } from './utils' ;
10
11
11
12
// See https://fumadocs.dev//docs/headless/source-api for more info
12
13
export const docs = loader ( {
@@ -18,14 +19,7 @@ export const docs = loader({
18
19
return createElement ( icons [ icon as keyof typeof icons ] ) ;
19
20
} ,
20
21
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 ) ;
29
23
} ,
30
24
// https://fumadocs.dev/docs/headless/source-api#page-tree-1
31
25
pageTree : {
Original file line number Diff line number Diff line change @@ -124,12 +124,26 @@ export const parseDocId = (id: string) => {
124
124
whereTag,
125
125
} ;
126
126
} ;
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 ) } ` ) ;
131
139
}
132
- return `/docs/${ ( slug || [ ] ) . join ( '/' ) } ` ;
140
+ return removeTrailingSlash (
141
+ `/docs/${ (
142
+ slugs . map ( ( slug ) => {
143
+ return slug . replace ( / ^ \d \d - / , '' ) ;
144
+ } )
145
+ ) . join ( '/' ) } `,
146
+ ) ;
133
147
}
134
148
135
149
export function getLearnUrl ( slug : string [ ] | string | undefined ) {
You can’t perform that action at this time.
0 commit comments