Skip to content

Commit 914244e

Browse files
authored
Merge pull request #12332 from ethereum/staging
Staging -> dev
2 parents 1a5985a + 3c29e40 commit 914244e

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

public/_redirects

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272

7373
/en/dart/ /en/developers/docs/programming-languages/dart/ 301!
7474

75-
/developers/docs/consensus-mechanisms/pow/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!
75+
/developers/docs/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!
7676

77-
/en/developers/docs/consensus-mechanisms/pow/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!
77+
/en/developers/docs/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!
7878

7979
/*/beginners /:splat/what-is-ethereum/ 301!
8080

src/components/PageMetadata.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getOgImage } from "@/lib/utils/metadata"
66
import { filterRealLocales } from "@/lib/utils/translations"
77
import { getFullUrl } from "@/lib/utils/url"
88

9-
import { SITE_URL } from "@/lib/constants"
9+
import { DEFAULT_LOCALE, SITE_URL } from "@/lib/constants"
1010

1111
type NameMeta = {
1212
name: string
@@ -52,6 +52,9 @@ const PageMetadata = ({
5252
const url = getFullUrl(locale, path)
5353
const canonical = canonicalUrl || url
5454

55+
// Set x-default URL for hreflang
56+
const xDefault = getFullUrl(DEFAULT_LOCALE, path)
57+
5558
/* Set fallback ogImage based on path */
5659
const ogImage = image || getOgImage(slug)
5760

@@ -85,6 +88,7 @@ const PageMetadata = ({
8588
/>
8689
))}
8790
<link rel="canonical" key={canonical} href={canonical} />
91+
<link rel="alternate" hrefLang="x-default" href={xDefault} />
8892
{locales.map((loc) => (
8993
<link
9094
key={loc}

src/data/developer-docs-links.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
to: /developers/docs/consensus-mechanisms/pow/mining/
7171
items:
7272
- id: docs-nav-mining-algorithms
73-
to: /developers/docs/consensus-mechanisms/pow/mining-algorithms/
73+
to: /developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/
7474
items:
7575
- id: docs-nav-dagger-hashimoto
76-
to: /developers/docs/consensus-mechanisms/pow/mining-algorithms/dagger-hashimoto/
76+
to: /developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/dagger-hashimoto/
7777
- id: docs-nav-ethash
78-
to: /developers/docs/consensus-mechanisms/pow/mining-algorithms/ethash/
78+
to: /developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/ethash/
7979
- id: docs-nav-proof-of-stake
8080
to: /developers/docs/consensus-mechanisms/pos/
8181
items:

src/lib/utils/md.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ const getPostSlugs = (dir: string, files: string[] = []) => {
6868
"/developers/docs/consensus-mechanisms/pos/weak-subjectivity",
6969
"/developers/docs/consensus-mechanisms/pow/",
7070
"/developers/docs/consensus-mechanisms/pow/mining",
71-
"/developers/docs/consensus-mechanisms/pow/mining-algorithms",
72-
"/developers/docs/consensus-mechanisms/pow/mining-algorithms/dagger-hashimoto",
73-
"/developers/docs/consensus-mechanisms/pow/mining-algorithms/ethash",
71+
"/developers/docs/consensus-mechanisms/pow/mining/mining-algorithms",
72+
"/developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/dagger-hashimoto",
73+
"/developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/ethash",
7474
"/developers/docs/dapps",
7575
"/developers/docs/data-and-analytics",
7676
"/developers/docs/data-and-analytics/block-explorers",

src/middleware.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ export async function middleware(req: NextRequest) {
3333
}
3434

3535
if (req.nextUrl.locale === FAKE_LOCALE) {
36-
// Apparently `localeDetection` does not work when using the faked locale
37-
// hack. So, detect the locale manually
36+
// Apparently, the built-in `localeDetection`from Next does not work when
37+
// using the faked locale hack. So, we need to detect the locale manually
3838
const localeDetected = detectLocale(req.headers.get("accept-language"))
3939
const locale = localeDetected || DEFAULT_LOCALE
4040

41-
return NextResponse.redirect(
42-
new URL(`/${locale}${req.nextUrl.pathname}`, req.url),
43-
{ status: 301 }
44-
)
41+
const redirectUrl = new URL(`/${locale}${req.nextUrl.pathname}`, req.url)
42+
43+
// Add trailing slash if it's not present
44+
if (!redirectUrl.pathname.endsWith("/")) {
45+
redirectUrl.pathname = redirectUrl.pathname + "/"
46+
}
47+
48+
return NextResponse.redirect(redirectUrl, { status: 301 })
4549
}
4650
}

0 commit comments

Comments
 (0)