Skip to content

Commit 56bbce7

Browse files
authored
Merge pull request #62 from ibelem/google-search-fix
fix: Google Search canonical/hreflang issues and Next.js 16 proxy migration
2 parents d241e5d + 6dede53 commit 56bbce7

9 files changed

Lines changed: 155 additions & 113 deletions

File tree

app/[lang]/[[...mdxPath]]/page.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ export const generateStaticParams = generateStaticParamsFor('mdxPath')
66
export async function generateMetadata(props) {
77
const params = await props.params;
88
const { metadata } = await importPage(params.mdxPath, params.lang);
9-
return metadata;
9+
const pagePath = params.mdxPath ? params.mdxPath.join('/') : '';
10+
return {
11+
...metadata,
12+
alternates: {
13+
canonical: `https://webnn.io/${params.lang}${pagePath ? '/' + pagePath : ''}`,
14+
languages: {
15+
'en': `https://webnn.io/en${pagePath ? '/' + pagePath : ''}`,
16+
'zh': `https://webnn.io/zh${pagePath ? '/' + pagePath : ''}`,
17+
'x-default': `https://webnn.io/en${pagePath ? '/' + pagePath : ''}`,
18+
},
19+
},
20+
};
1021
}
1122

1223
const Wrapper = useMDXComponents().wrapper;

app/[lang]/layout.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ export const metadata = {
4848
},
4949
alternates: {
5050
canonical: './',
51-
languages: {
52-
'en': '/en',
53-
'zh': '/zh',
54-
'x-default': '/en',
55-
},
5651
},
5752
robots: {
5853
index: true,

app/[lang]/playground/page.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
import { Playground } from '../../_components/playground'
22
import { GoogleAnalytics } from '@next/third-parties/google'
33

4+
export async function generateMetadata(props) {
5+
const { lang } = await props.params;
6+
return {
7+
alternates: {
8+
canonical: `https://webnn.io/${lang}/playground`,
9+
languages: {
10+
'en': 'https://webnn.io/en/playground',
11+
'zh': 'https://webnn.io/zh/playground',
12+
'x-default': 'https://webnn.io/en/playground',
13+
},
14+
},
15+
};
16+
}
17+
418
export default function Page() {
519
return (
620
<div>

app/[lang]/showcase/page.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
import { Showcases } from "../../_components/showcases/showcases.jsx"
22
import { GoogleAnalytics } from '@next/third-parties/google'
33

4+
export async function generateMetadata(props) {
5+
const { lang } = await props.params;
6+
return {
7+
alternates: {
8+
canonical: `https://webnn.io/${lang}/showcase`,
9+
languages: {
10+
'en': 'https://webnn.io/en/showcase',
11+
'zh': 'https://webnn.io/zh/showcase',
12+
'x-default': 'https://webnn.io/en/showcase',
13+
},
14+
},
15+
};
16+
}
17+
418
export default async function Page() {
519
return (
620
<div className="md:px-8 xl:px-8">

content/en/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: WebNN Docs
3+
---
4+
15
import Netron from '../../app/_components/netron/netron'
26
import Hero from '../../app/_components/home/hero'
37
import HeroBackground from '../../app/_components/home/bg'

content/zh/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: WebNN 文档
3+
---
4+
15
import Netron from '../../app/_components/netron/netron'
26
import HeroCh from '../../app/_components/home/hero-ch'
37
import HeroBackground from '../../app/_components/home/bg'

middleware.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

proxy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export { proxy } from 'nextra/locales'
2+
3+
export const config = {
4+
// Matcher for locale routing - includes root path
5+
matcher: [
6+
'/((?!api|_next/static|_next/image|favicon.ico|icon.svg|icon-512.png|apple-icon.png|android-chrome-512x512.png|manifest|_pagefind|llms.txt|netron|demos|robots.txt|sitemap.xml|.well-known).*)'
7+
]
8+
}

public/sitemap.xml

Lines changed: 99 additions & 99 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)