Skip to content

Commit 5bce2ee

Browse files
authored
Merge branch 'dev' into removeComponentsFromTsconfig
2 parents 80a6d19 + 931b249 commit 5bce2ee

File tree

12 files changed

+177
-175
lines changed

12 files changed

+177
-175
lines changed

src/components/Codeblock.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useEffect, useState } from "react"
1+
import React, { useState } from "react"
2+
import { useTranslation } from "next-i18next"
23
import Highlight, {
34
defaultProps,
45
Language,
@@ -9,9 +10,9 @@ import { Box, BoxProps, Flex, useColorModeValue } from "@chakra-ui/react"
910

1011
import CopyToClipboard from "@/components/CopyToClipboard"
1112
import Emoji from "@/components/Emoji"
12-
1313
// https://github.com/FormidableLabs/prism-react-renderer/tree/master#custom-language-support
14-
;(typeof global !== "undefined" ? global : window).Prism = Prism
14+
;
15+
(typeof global !== "undefined" ? global : window).Prism = Prism
1516
require("prismjs/components/prism-solidity")
1617

1718
const LINES_BEFORE_COLLAPSABLE = 8
@@ -217,6 +218,7 @@ const Codeblock: React.FC<IProps> = ({
217218
codeLanguage,
218219
fromHomepage = false,
219220
}) => {
221+
const { t } = useTranslation('common')
220222
const selectedTheme = useColorModeValue(codeTheme.light, codeTheme.dark)
221223

222224
const codeText = React.Children.toArray(children)
@@ -321,13 +323,9 @@ const Codeblock: React.FC<IProps> = ({
321323
totalLines - 1 > LINES_BEFORE_COLLAPSABLE && (
322324
<TopBarItem onClick={() => setIsCollapsed(!isCollapsed)}>
323325
{isCollapsed ? (
324-
// TODO: Implement after intl
325-
// <Translation id="show-all" />
326-
<>Show all</>
326+
t("show-all")
327327
) : (
328-
// TODO: Implement after intl
329-
// <Translation id="show-less" />
330-
<>Show less</>
328+
t("show-less")
331329
)}
332330
</TopBarItem>
333331
)}
@@ -338,16 +336,12 @@ const Codeblock: React.FC<IProps> = ({
338336
{!isCopied ? (
339337
<>
340338
<Emoji text=":clipboard:" fontSize="md" />{" "}
341-
{/* TODO: Implement after intl */}
342-
{/* <Translation id="copy" /> */}
343-
Copy
339+
{t("copy")}
344340
</>
345341
) : (
346342
<>
347343
<Emoji text=":white_check_mark:" fontSize="md" />{" "}
348-
{/* TODO: Implement after intl */}
349-
{/* <Translation id="copied" /> */}
350-
Copied
344+
{t("copied")}
351345
</>
352346
)}
353347
</TopBarItem>

src/components/ExpandableCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const ExpandableCard = ({
3434
eventName = "",
3535
}: ExpandableCardProps) => {
3636
const [isVisible, setIsVisible] = useState(false)
37-
const { t } = useTranslation("common") // TODO: Double-check namespace
37+
const { t } = useTranslation("common")
3838
const matomo = {
3939
eventAction,
4040
eventCategory: `ExpandableCard${eventCategory}`,

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/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/Staking/StakingProductsCardGrid.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
UnknownProductGlyphIcon,
2626
WarningProductGlyphIcon,
2727
} from "@/components/icons/staking"
28-
import Translation from "@/components/Translation"
2928

3029
import { MatomoEventOptions } from "@/lib/utils/matomo"
3130

@@ -276,8 +275,7 @@ const StakingProductCard: React.FC<ICardProps> = ({
276275
</List>
277276
</Box>
278277
<Box {...PADDED_DIV_STYLE}>
279-
{/* TODO: Matomo - re-enable */}
280-
<ButtonLink to={url} /* customEventOptions={matomo} */ width="100%">
278+
<ButtonLink to={url} customEventOptions={matomo} width="100%">
281279
{t("page-staking-products-get-started")}
282280
</ButtonLink>
283281
</Box>

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

src/components/TableOfContents/index.tsx

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
Icon,
88
List,
99
ListItem,
10-
Show,
1110
useToken,
1211
} from "@chakra-ui/react"
1312

@@ -68,47 +67,46 @@ const TableOfContents: React.FC<IProps> = ({
6867
}
6968

7069
return (
71-
<Show above={lgBp}>
72-
<Box
73-
as="aside"
74-
position="sticky"
75-
top="7.25rem" // Account for navbar
76-
p={4}
77-
pe={0}
78-
maxW="25%"
79-
minW={48}
80-
height={calc.subtract("100vh", "80px")}
81-
overflowY="auto"
82-
{...rest}
83-
>
84-
<List {...outerListProps}>
85-
{!hideEditButton && editPath && (
86-
<ListItem mb={2}>
87-
<ButtonLink
88-
leftIcon={<Icon as={FaGithub} />}
89-
href={editPath}
90-
variant="outline"
91-
>
92-
{t("edit-page")}
93-
</ButtonLink>
94-
</ListItem>
95-
)}
96-
<ListItem>
97-
<Box mb={2} textTransform="uppercase">
98-
{t("on-this-page")}
99-
</Box>
100-
<List m={0}>
101-
<ItemsList
102-
items={items}
103-
depth={0}
104-
maxDepth={maxDepth ? maxDepth : 1}
105-
activeHash={activeHash}
106-
/>
107-
</List>
70+
<Box
71+
hideBelow={lgBp}
72+
as="aside"
73+
position="sticky"
74+
top="7.25rem" // Account for navbar
75+
p={4}
76+
pe={0}
77+
maxW="25%"
78+
minW={48}
79+
height={calc.subtract("100vh", "80px")}
80+
overflowY="auto"
81+
{...rest}
82+
>
83+
<List {...outerListProps}>
84+
{!hideEditButton && editPath && (
85+
<ListItem mb={2}>
86+
<ButtonLink
87+
leftIcon={<Icon as={FaGithub} />}
88+
href={editPath}
89+
variant="outline"
90+
>
91+
{t("edit-page")}
92+
</ButtonLink>
10893
</ListItem>
109-
</List>
110-
</Box>
111-
</Show>
94+
)}
95+
<ListItem>
96+
<Box mb={2} textTransform="uppercase">
97+
{t("on-this-page")}
98+
</Box>
99+
<List m={0}>
100+
<ItemsList
101+
items={items}
102+
depth={0}
103+
maxDepth={maxDepth ? maxDepth : 1}
104+
activeHash={activeHash}
105+
/>
106+
</List>
107+
</ListItem>
108+
</List>
109+
</Box>
112110
)
113111
}
114112

0 commit comments

Comments
 (0)