Skip to content

Commit fb34b32

Browse files
authored
Merge pull request #156 from ethereum/layout-algolia
Fix Algolia crawler DOM dependencies
2 parents a7da39d + 8b8ff20 commit fb34b32

38 files changed

+195
-136
lines changed

src/components/MainArticle.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Box, type BoxProps } from "@chakra-ui/react"
2+
3+
import { MAIN_CONTENT_ID } from "@/lib/constants"
4+
5+
const MainArticle = (props: BoxProps) => (
6+
<Box as="article" id={MAIN_CONTENT_ID} tabIndex={-1} {...props} />
7+
)
8+
9+
export default MainArticle

src/components/MdComponents.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import DocLink from "./DocLink"
3939
import Emoji from "./Emoji"
4040
import ExpandableCard from "./ExpandableCard"
4141
import InfoBanner from "./InfoBanner"
42+
import MainArticle from "./MainArticle"
4243

4344
/**
4445
* Base HTML elements
@@ -185,7 +186,7 @@ export const ContentContainer = (props: Pick<BoxProps, "id" | "children">) => {
185186

186187
return (
187188
<Box
188-
as="article"
189+
as={MainArticle}
189190
flex={`1 1 ${lgBp}`}
190191
position="relative"
191192
px={8}

src/layouts/Docs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import GitHubContributors from "@/components/GitHubContributors"
3131
import GlossaryTooltip from "@/components/Glossary/GlossaryTooltip"
3232
import InfoBanner from "@/components/InfoBanner"
3333
import Link from "@/components/Link"
34+
import MainArticle from "@/components/MainArticle"
3435
import {
3536
Heading1 as MdHeading1,
3637
Heading2 as MdHeading2,
@@ -86,6 +87,7 @@ const baseHeadingStyle: HeadingProps = {
8687
fontFamily: "mono",
8788
textTransform: "uppercase",
8889
fontWeight: "bold",
90+
scrollMarginTop: 40,
8991
}
9092

9193
const H1 = (props: HeadingProps) => (
@@ -141,7 +143,7 @@ const Content = (props: ChildOnlyProp) => {
141143

142144
return (
143145
<Box
144-
as="article"
146+
as={MainArticle}
145147
flex={`1 1 ${mdBreakpoint}`}
146148
maxW={{ base: "full", lg: mdBreakpoint }}
147149
pt={{ base: 32, md: 12 }}

src/layouts/Roadmap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export const RoadmapLayout: React.FC<IProps> = ({
195195
maxDepth={frontmatter.sidebarDepth!}
196196
tocItems={tocItems}
197197
/>
198-
<ContentContainer id="content">
198+
<ContentContainer>
199199
{children}
200200
<FeedbackCard />
201201
</ContentContainer>

src/layouts/Staking.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export const StakingLayout: React.FC<IProps> = ({
287287
tocItems={tocItems}
288288
maxDepth={frontmatter.sidebarDepth!}
289289
/>
290-
<ContentContainer id="content">
290+
<ContentContainer>
291291
{children}
292292
<StakingCommunityCallout my={16} />
293293
<FeedbackCard />

src/layouts/Static.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { HubHero } from "@/components/Hero"
1414
import NetworkUpgradeSummary from "@/components/History/NetworkUpgradeSummary"
1515
import Link from "@/components/Link"
1616
import Logo from "@/components/Logo"
17+
import MainArticle from "@/components/MainArticle"
1718
import MatomoOptOut from "@/components/MatomoOptOut"
1819
import {
1920
Heading1 as MdHeading1,
@@ -127,7 +128,7 @@ export const StaticLayout: React.FC<IProps> = ({
127128
)}
128129

129130
<Box
130-
as="article"
131+
as={MainArticle}
131132
maxW="container.md"
132133
w="full"
133134
sx={{

src/layouts/Tutorial.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useRouter } from "next/router"
22
import {
33
Badge,
44
Box,
5-
type BoxProps,
65
chakra,
76
Divider,
87
Flex,
@@ -17,7 +16,6 @@ import type { ChildOnlyProp, TranslationKey } from "@/lib/types"
1716
import type { MdPageContent, TutorialFrontmatter } from "@/lib/interfaces"
1817

1918
import PostMergeBanner from "@/components/Banners/PostMergeBanner"
20-
// Components
2119
import { ButtonLink } from "@/components/Buttons"
2220
import CallToContribute from "@/components/CallToContribute"
2321
import Card from "@/components/Card"
@@ -29,13 +27,15 @@ import FeedbackCard from "@/components/FeedbackCard"
2927
import GitHubContributors from "@/components/GitHubContributors"
3028
import GlossaryTooltip from "@/components/Glossary/GlossaryTooltip"
3129
import InfoBanner from "@/components/InfoBanner"
30+
import MainArticle from "@/components/MainArticle"
3231
import {
3332
Heading1 as MdHeading1,
3433
Heading2 as MdHeading2,
3534
Heading3 as MdHeading3,
3635
Heading4 as MdHeading4,
3736
} from "@/components/MdComponents"
3837
import MdLink from "@/components/MdLink"
38+
import PageMetadata from "@/components/PageMetadata"
3939
import { mdxTableComponents } from "@/components/Table"
4040
import TableOfContents from "@/components/TableOfContents"
4141
import TutorialMetadata from "@/components/TutorialMetadata"
@@ -45,13 +45,13 @@ import { DEFAULT_LOCALE, EDIT_CONTENT_URL } from "@/lib/constants"
4545

4646
import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"
4747

48-
const ContentContainer = (props: Pick<BoxProps, "id" | "children">) => {
48+
const ContentContainer = (props: ChildOnlyProp) => {
4949
const boxShadow = useToken("colors", "tableBoxShadow")
5050
const borderColor = useToken("colors", "primary.base")
5151

5252
return (
5353
<Box
54-
as="article"
54+
as={MainArticle}
5555
maxW="1000px"
5656
minW={0}
5757
background="background.base"

src/layouts/Upgrade.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useTranslation } from "next-i18next"
33
import { MdExpandMore } from "react-icons/md"
44
import {
55
Box,
6-
Center,
76
Flex,
87
type FlexProps,
98
Icon,
@@ -14,7 +13,7 @@ import {
1413
useToken,
1514
} from "@chakra-ui/react"
1615

17-
import type { ChildOnlyProp, Lang /* Context */ } from "@/lib/types"
16+
import type { ChildOnlyProp, Lang } from "@/lib/types"
1817
import type { MdPageContent, UpgradeFrontmatter } from "@/lib/interfaces"
1918

2019
import BeaconChainActions from "@/components/BeaconChainActions"
@@ -38,6 +37,8 @@ import UpgradeStatus from "@/components/UpgradeStatus"
3837
import { getSummaryPoints } from "@/lib/utils/getSummaryPoints"
3938
import { getLocaleTimestamp } from "@/lib/utils/time"
4039

40+
import { MAIN_CONTENT_ID } from "@/lib/constants"
41+
4142
const Page = (props: FlexProps) => <MdPage sx={{}} {...props} />
4243

4344
const Title = (props: ChildOnlyProp) => (
@@ -205,7 +206,7 @@ export const UpgradeLayout: React.FC<IProps> = ({
205206
)}
206207
</HeroContainer>
207208
<Show above={lgBreakpoint}>
208-
<MoreContent to="#content">
209+
<MoreContent to={"#" + MAIN_CONTENT_ID}>
209210
<Icon as={MdExpandMore} fontSize="2xl" color="secondary" />
210211
</MoreContent>
211212
</Show>
@@ -217,7 +218,7 @@ export const UpgradeLayout: React.FC<IProps> = ({
217218
tocItems={tocItems}
218219
maxDepth={frontmatter.sidebarDepth!}
219220
/>
220-
<ContentContainer id="content">
221+
<ContentContainer>
221222
{children}
222223
<FeedbackCard />
223224
</ContentContainer>

src/layouts/UseCases.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import TableOfContents from "@/components/TableOfContents"
3434

3535
import { getSummaryPoints } from "@/lib/utils/getSummaryPoints"
3636

37-
import { EDIT_CONTENT_URL } from "@/lib/constants"
37+
import { EDIT_CONTENT_URL, MAIN_CONTENT_ID } from "@/lib/constants"
3838

3939
const HeroContainer = (props: ChildOnlyProp) => (
4040
<Flex
@@ -236,7 +236,7 @@ export const UseCasesLayout: React.FC<IProps> = ({
236236
<Show above={lgBp}>
237237
<Flex
238238
as={BaseLink}
239-
to="#content"
239+
to={"#" + MAIN_CONTENT_ID}
240240
bg="ednBackground"
241241
justifyContent="center"
242242
p={4}
@@ -256,7 +256,7 @@ export const UseCasesLayout: React.FC<IProps> = ({
256256
tocItems={tocItems}
257257
maxDepth={frontmatter.sidebarDepth!}
258258
/>
259-
<ContentContainer id="content">
259+
<ContentContainer>
260260
{children}
261261
<FeedbackCard />
262262
</ContentContainer>

src/lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const LOCALES_CODES = BUILD_LOCALES
1919
export const SITE_URL = "https://ethereum.org"
2020
export const DISCORD_PATH = "/discord/"
2121
export const EDIT_CONTENT_URL = `https://github.com/ethereum/ethereum-org-website/tree/dev/`
22+
export const MAIN_CONTENT_ID = "main-content"
2223
export const WEBSITE_EMAIL = "website@ethereum.org"
2324

2425
// Config

0 commit comments

Comments
 (0)