Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/LeftSidebar/LeftSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ const currentPageMatch = removeSlashes(currentPage.slice(1))
<>
<li class="nav-link">
<a
href={isExternal(child.url) ? `${child.url}` : localizePath("/docs/" + child.url)}
href={isExternal(child.url) ? `${child.url}` : localizePath(child.url)}
target={isExternal(child.url) ? "_blank" : "_self"}
aria-current={`${currentPage === localizePath("/docs/" + child.url) ? "page" : "false"}`}
aria-current={`${
currentPageMatch === removeSlashes(localizePath(child.url)) ? "page" : "false"
}`}
>
{child.title}
{isExternal(child.url) && (
Expand All @@ -77,10 +79,10 @@ const currentPageMatch = removeSlashes(currentPage.slice(1))
{child.children.map((childItem) => (
<li class="nav-link nested">
<a
href={isExternal(childItem.url) ? childItem.url : localizePath("/docs/" + childItem.url)}
href={isExternal(childItem.url) ? childItem.url : localizePath(childItem.url)}
target={isExternal(child.url) ? "_blank" : "_self"}
aria-current={`${
currentPage === localizePath("/docs/" + childItem.url) ? "page" : "false"
currentPageMatch === removeSlashes(localizePath(childItem.url)) ? "page" : "false"
}`}
>
{childItem.title}
Expand Down
16 changes: 8 additions & 8 deletions src/config/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ export const MENU: MenuItems = {
en: [
{
text: "Getting Started",
link: "/en/docs/getting-started/overview",
link: "/en/getting-started/overview",
section: "gettingStarted",
},
{ text: "Developers", link: "/en/docs/developers", section: "developers" },
{ text: "Technology", link: "/en/docs/technology", section: "technology" },
{ text: "Learn", link: "/en/docs/learn", section: "learn" },
{ text: "Developers", link: "/en/developers", section: "developers" },
{ text: "Technology", link: "/en/technology", section: "technology" },
{ text: "Learn", link: "/en/learn", section: "learn" },
],
zh: [
{
text: "入门",
link: "/zh/docs/getting-started/overview",
link: "/zh/getting-started/overview",
section: "gettingStarted",
},
{ text: "开发者", link: "/zh/docs/developers", section: "developers" },
{ text: "技术", link: "/zh/docs/technology", section: "technology" },
{ text: "学习", link: "/zh/docs/learn", section: "learn" },
{ text: "开发者", link: "/zh/developers", section: "developers" },
{ text: "技术", link: "/zh/technology", section: "technology" },
{ text: "学习", link: "/zh/learn", section: "learn" },
],
}
20 changes: 11 additions & 9 deletions src/config/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { t } from "i18next"
import i18next, { t } from "i18next"

const formatUrl = (url) => `${i18next.language}/${url}`

export const getSidebar = () => {
return {
Expand All @@ -12,27 +14,27 @@ export const getSidebar = () => {
contents: [
{
title: t("sidebar.gettingStarted.userGuide"),
url: "user-guide/",
url: formatUrl("user-guide/"),
children: [
{
title: t("sidebar.gettingStarted.setup"),
url: "user-guide/setup",
url: formatUrl("user-guide/setup"),
},
{
title: t("sidebar.gettingStarted.faucet"),
url: "user-guide/faucet",
url: formatUrl("user-guide/faucet"),
},
{
title: t("sidebar.gettingStarted.bridge"),
url: "user-guide/bridge",
url: formatUrl("user-guide/bridge"),
},
{
title: t("sidebar.gettingStarted.transferTokens"),
url: "user-guide/transfer-tokens",
url: formatUrl("user-guide/transfer-tokens"),
},
{
title: t("sidebar.gettingStarted.commonErrors"),
url: "user-guide/common-errors",
url: formatUrl("user-guide/common-errors"),
},
],
},
Expand Down Expand Up @@ -66,7 +68,7 @@ export const getSidebar = () => {
{ title: t("sidebar.developers.integrations"), url: "developers/integrations" },
{
title: t("sidebar.developers.ethereum&AlphaTestnetDifferences"),
url: "developers/ethereum-and-alpha-testnet-differences",
url: formatUrl("developers/ethereum-and-alpha-testnet-differences"),
},
],
},
Expand All @@ -75,7 +77,7 @@ export const getSidebar = () => {
contents: [
{
title: t("sidebar.developers.contractDeploymentTutorial"),
url: "developers/guides/contract-deployment-tutorial",
url: formatUrl("developers/guides/contract-deployment-tutorial"),
},
],
},
Expand Down
19 changes: 17 additions & 2 deletions src/pages/[...redirect].astro
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
---
import { changeLanguage } from "i18next"
import i18next, { t, changeLanguage } from "i18next"
import { GetStaticPathsResult } from "astro"
import redirects from "../features/redirects/redirects.json"
import { getCollection } from "astro:content"

changeLanguage("en")

export async function getStaticPaths(): Promise<GetStaticPathsResult> {
const pages = await getCollection("docs")
const allSlugs = new Set(
pages.map((page) => {
const [, ...slug] = page.slug.split("/")
return slug.join("/")
})
)

const sanitizeSource = (source: string) => {
let newSource = source
if (newSource[newSource.length - 1] === "/") newSource = newSource.slice(0, newSource.length - 1)
if (newSource[0] === "/") return newSource.slice(1, newSource.length)
return newSource
}
return redirects.redirects.map((entry) => {

const paths = redirects.redirects.map((entry) => {
return {
params: { redirect: sanitizeSource(entry.source) },
props: {
Expand All @@ -23,6 +33,11 @@ export async function getStaticPaths(): Promise<GetStaticPathsResult> {
},
}
})

for (let slug of allSlugs) {
paths.push({ params: { redirect: slug }, props: { to: `/en/${slug}` } })
}
return paths
}
const { to } = Astro.props
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { getCollection } from "astro:content"
import i18next, { t, changeLanguage } from "i18next"
import MainLayout from "../../../layouts/MainLayout.astro"
import MainLayout from "../../layouts/MainLayout.astro"

export async function getStaticPaths() {
const pages = await getCollection("docs")
Expand Down