Skip to content

Commit 445a8f4

Browse files
committed
Merge branch 'dev' into stats-box-grid
2 parents 5e42609 + 18af315 commit 445a8f4

File tree

8 files changed

+155
-281
lines changed

8 files changed

+155
-281
lines changed

src/components/PageMetadata.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import Head from "next/head"
44
import { useRouter } from "next/router"
55
import { useTranslation } from "next-i18next"
66

7-
import { DEFAULT_LOCALE, SITE_URL } from "@/lib/constants"
8-
9-
import ogImageDapps from "@/public/doge-computer.png"
10-
import ogImageDevelopers from "@/public/enterprise-eth.png"
11-
import ogImageDefault from "@/public/home/hero.png"
12-
import ogImageUpgrades from "@/public/upgrades/upgrade_doge.png"
7+
import { SITE_URL } from "@/lib/constants"
138

149
type NameMeta = {
1510
name: string
@@ -44,33 +39,38 @@ const PageMetadata: React.FC<IProps> = ({
4439
const desc = description || t("site-description")
4540
const siteTitle = t("site-title")
4641
const fullTitle = `${title} | ${siteTitle}`
42+
const origin = process.env.NEXT_PUBLIC_SITE_URL || SITE_URL // TODO: Remove .env var usage after launch
43+
44+
// Remove any query params (?) or hash links (#)
45+
const path = asPath.replace(/[\?\#].*/, "")
46+
const slug = path.split("/")
4747

4848
/* Set canonical URL w/ language path to avoid duplicate content */
4949
/* e.g. set ethereum.org/about/ to ethereum.org/en/about/ */
50-
const canonical = canonicalUrl || join(SITE_URL, DEFAULT_LOCALE, asPath)
51-
const url = locale ? join(SITE_URL, locale, asPath) : canonical
50+
const url = new URL(join(locale!, path), origin).href
51+
const canonical = canonicalUrl || url
5252

5353
/* Set fallback ogImage based on path */
54-
let ogImage = ogImageDefault.src
54+
let ogImage = "/home/hero.png"
5555

56-
if (asPath.includes("/developers/")) {
57-
ogImage = ogImageDevelopers.src
56+
if (slug.includes("developers")) {
57+
ogImage = "/enterprise-eth.png"
5858
}
5959

60-
if (asPath.includes("/dapps/")) {
61-
ogImage = ogImageDapps.src
60+
if (slug.includes("dapps")) {
61+
ogImage = "/doge-computer.png"
6262
}
6363

64-
if (asPath.includes("/roadmap/")) {
65-
ogImage = ogImageUpgrades.src
64+
if (slug.includes("roadmap")) {
65+
ogImage = "/upgrades/upgrade_doge.png"
6666
}
6767

6868
if (image) {
6969
ogImage = image
7070
}
7171

72-
const ogImageUrl = join(SITE_URL, ogImage)
73-
const metadata: Array<Meta> = [
72+
const ogImageUrl = new URL(ogImage, origin).href
73+
const metadata: Meta[] = [
7474
{ name: `description`, content: desc },
7575
{ name: `image`, content: ogImageUrl },
7676
{ property: `og:title`, content: fullTitle },

src/components/ReleaseBanner.tsx

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

src/components/SideNav.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ const SideNavLink = ({ children, ...props }: LinkProps) => {
6666
export interface IPropsNavLink {
6767
item: DeveloperDocsLink
6868
path: string
69+
isTopLevel?: boolean
6970
}
7071

71-
const NavLink: React.FC<IPropsNavLink> = ({ item, path }) => {
72+
const NavLink: React.FC<IPropsNavLink> = ({ item, path, isTopLevel }) => {
7273
const { t } = useTranslation("page-developers-docs")
73-
const isLinkInPath = path.includes(item.to) || path.includes(item.path)
74+
const isLinkInPath =
75+
isTopLevel || path.includes(item.to) || path.includes(item.path)
7476
const [isOpen, setIsOpen] = useState<boolean>(isLinkInPath)
7577

7678
useEffect(() => {
@@ -115,7 +117,7 @@ const NavLink: React.FC<IPropsNavLink> = ({ item, path }) => {
115117
key={item.id}
116118
animate={isOpen ? "open" : "closed"}
117119
variants={innerLinksVariants}
118-
initial="closed"
120+
initial={isOpen ? "open" : "closed"}
119121
>
120122
{item.items.map((childItem, idx) => (
121123
<NavLink item={childItem} path={path} key={idx} />
@@ -166,7 +168,7 @@ const SideNav = ({ path }: SideNavProps) => {
166168
aria-label={t("common:nav-developers-docs")}
167169
>
168170
{docLinks.map((item, idx) => (
169-
<NavLink item={item} path={path} key={idx} />
171+
<NavLink item={item} path={path} key={idx} isTopLevel />
170172
))}
171173
</Box>
172174
)

src/components/TableOfContents/TableOfContentsMobile.tsx

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,49 +37,47 @@ const Mobile: React.FC<IPropsTableOfContentsMobile> = ({ items, maxDepth }) => {
3737
}
3838

3939
return (
40-
<Show below={lgBp}>
41-
{/* TODO: switch `l` to `lg` after UI migration and use `hideBelow` prop */}
42-
<Box
43-
as="aside"
44-
background="background.base"
45-
border="1px"
46-
borderColor="border"
47-
borderRadius="4px"
48-
py={2}
49-
px={4}
40+
<Box
41+
hideFrom={lgBp}
42+
as="aside"
43+
background="background.base"
44+
border="1px"
45+
borderColor="border"
46+
borderRadius="4px"
47+
py={2}
48+
px={4}
49+
>
50+
<Flex
51+
color="text200"
52+
cursor="pointer"
53+
alignItems="center"
54+
justify="space-between"
55+
{...getButtonProps()}
5056
>
51-
<Flex
52-
color="text200"
53-
cursor="pointer"
54-
alignItems="center"
55-
justify="space-between"
56-
{...getButtonProps()}
57-
>
58-
<chakra.span flex={1} fontWeight={500}>
59-
{t("on-this-page")}
60-
</chakra.span>
61-
<Icon
62-
as={MdExpandMore}
63-
transform={isOpen ? "rotate(0)" : "rotate(-90deg)"}
64-
boxSize={6}
65-
transition="transform .4s"
57+
<chakra.span flex={1} fontWeight={500}>
58+
{t("on-this-page")}
59+
</chakra.span>
60+
<Icon
61+
as={MdExpandMore}
62+
transform={isOpen ? "rotate(0)" : "rotate(-90deg)"}
63+
boxSize={6}
64+
transition="transform .4s"
65+
/>
66+
</Flex>
67+
<Fade
68+
in={isOpen}
69+
{...getDisclosureProps()}
70+
transition={{ enter: { duration: 0.6 } }}
71+
>
72+
<List {...outerListProps}>
73+
<ItemsList
74+
items={items}
75+
depth={0}
76+
maxDepth={maxDepth ? maxDepth : 1}
6677
/>
67-
</Flex>
68-
<Fade
69-
in={isOpen}
70-
{...getDisclosureProps()}
71-
transition={{ enter: { duration: 0.6 } }}
72-
>
73-
<List {...outerListProps}>
74-
<ItemsList
75-
items={items}
76-
depth={0}
77-
maxDepth={maxDepth ? maxDepth : 1}
78-
/>
79-
</List>
80-
</Fade>
81-
</Box>
82-
</Show>
78+
</List>
79+
</Fade>
80+
</Box>
8381
)
8482
}
8583

0 commit comments

Comments
 (0)