Skip to content

Commit

Permalink
Merge pull request #12332 from ethereum/staging
Browse files Browse the repository at this point in the history
Staging -> dev
  • Loading branch information
corwintines authored Mar 1, 2024
2 parents 1a5985a + 3c29e40 commit 914244e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@

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

/developers/docs/consensus-mechanisms/pow/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!
/developers/docs/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!

/en/developers/docs/consensus-mechanisms/pow/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!
/en/developers/docs/mining/ /en/developers/docs/consensus-mechanisms/pow/mining/ 301!

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

Expand Down
6 changes: 5 additions & 1 deletion src/components/PageMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getOgImage } from "@/lib/utils/metadata"
import { filterRealLocales } from "@/lib/utils/translations"
import { getFullUrl } from "@/lib/utils/url"

import { SITE_URL } from "@/lib/constants"
import { DEFAULT_LOCALE, SITE_URL } from "@/lib/constants"

type NameMeta = {
name: string
Expand Down Expand Up @@ -52,6 +52,9 @@ const PageMetadata = ({
const url = getFullUrl(locale, path)
const canonical = canonicalUrl || url

// Set x-default URL for hreflang
const xDefault = getFullUrl(DEFAULT_LOCALE, path)

/* Set fallback ogImage based on path */
const ogImage = image || getOgImage(slug)

Expand Down Expand Up @@ -85,6 +88,7 @@ const PageMetadata = ({
/>
))}
<link rel="canonical" key={canonical} href={canonical} />
<link rel="alternate" hrefLang="x-default" href={xDefault} />
{locales.map((loc) => (
<link
key={loc}
Expand Down
6 changes: 3 additions & 3 deletions src/data/developer-docs-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
to: /developers/docs/consensus-mechanisms/pow/mining/
items:
- id: docs-nav-mining-algorithms
to: /developers/docs/consensus-mechanisms/pow/mining-algorithms/
to: /developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/
items:
- id: docs-nav-dagger-hashimoto
to: /developers/docs/consensus-mechanisms/pow/mining-algorithms/dagger-hashimoto/
to: /developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/dagger-hashimoto/
- id: docs-nav-ethash
to: /developers/docs/consensus-mechanisms/pow/mining-algorithms/ethash/
to: /developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/ethash/
- id: docs-nav-proof-of-stake
to: /developers/docs/consensus-mechanisms/pos/
items:
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ const getPostSlugs = (dir: string, files: string[] = []) => {
"/developers/docs/consensus-mechanisms/pos/weak-subjectivity",
"/developers/docs/consensus-mechanisms/pow/",
"/developers/docs/consensus-mechanisms/pow/mining",
"/developers/docs/consensus-mechanisms/pow/mining-algorithms",
"/developers/docs/consensus-mechanisms/pow/mining-algorithms/dagger-hashimoto",
"/developers/docs/consensus-mechanisms/pow/mining-algorithms/ethash",
"/developers/docs/consensus-mechanisms/pow/mining/mining-algorithms",
"/developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/dagger-hashimoto",
"/developers/docs/consensus-mechanisms/pow/mining/mining-algorithms/ethash",
"/developers/docs/dapps",
"/developers/docs/data-and-analytics",
"/developers/docs/data-and-analytics/block-explorers",
Expand Down
16 changes: 10 additions & 6 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ export async function middleware(req: NextRequest) {
}

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

return NextResponse.redirect(
new URL(`/${locale}${req.nextUrl.pathname}`, req.url),
{ status: 301 }
)
const redirectUrl = new URL(`/${locale}${req.nextUrl.pathname}`, req.url)

// Add trailing slash if it's not present
if (!redirectUrl.pathname.endsWith("/")) {
redirectUrl.pathname = redirectUrl.pathname + "/"
}

return NextResponse.redirect(redirectUrl, { status: 301 })
}
}

0 comments on commit 914244e

Please sign in to comment.