Skip to content

Commit 53fb9ca

Browse files
committed
implement MAIN_CONTENT_ID in layouts
uncomment PageMetadata on layouts
1 parent 2cc2210 commit 53fb9ca

File tree

9 files changed

+37
-28
lines changed

9 files changed

+37
-28
lines changed

src/components/MdComponents.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import OldHeading from "@/components/OldHeading"
3232
import { mdxTableComponents } from "@/components/Table"
3333
import YouTube from "@/components/YouTube"
3434

35+
import { MAIN_CONTENT_ID } from "@/lib/constants"
36+
3537
import GlossaryTooltip from "./Glossary/GlossaryTooltip"
3638
import { StandaloneQuizWidget } from "./Quiz/QuizWidget"
3739
import Card from "./Card"
@@ -187,6 +189,7 @@ export const ContentContainer = (props: Pick<BoxProps, "id" | "children">) => {
187189
return (
188190
<Box
189191
as="article"
192+
id={MAIN_CONTENT_ID}
190193
flex={`1 1 ${lgBp}`}
191194
position="relative"
192195
px={8}

src/layouts/Docs.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ import {
3838
Heading4 as MdHeading4,
3939
Paragraph,
4040
} from "@/components/MdComponents"
41-
// TODO: IMPLEMENT PAGEMETADATA
42-
// import PageMetadata from "@/components/PageMetadata"
41+
import PageMetadata from "@/components/PageMetadata"
4342
import RollupProductDevDoc from "@/components/RollupProductDevDoc"
4443
import SideNav from "@/components/SideNav"
4544
import SideNavMobile from "@/components/SideNavMobile"
@@ -49,7 +48,11 @@ import Translation from "@/components/Translation"
4948
import YouTube from "@/components/YouTube"
5049

5150
// Utils
52-
import { DEFAULT_LOCALE, EDIT_CONTENT_URL } from "@/lib/constants"
51+
import {
52+
DEFAULT_LOCALE,
53+
EDIT_CONTENT_URL,
54+
MAIN_CONTENT_ID,
55+
} from "@/lib/constants"
5356

5457
import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"
5558

@@ -138,7 +141,7 @@ const ListItem = (props: ListItemProps) => (
138141
)
139142

140143
// Apply styles for classes within markdown here
141-
const Content = (props: ChildOnlyProp) => {
144+
const Content = (props: Pick<FlexProps, "children" | "id">) => {
142145
const mdBreakpoint = useToken("breakpoints", "md")
143146

144147
return (
@@ -235,11 +238,10 @@ export const DocsLayout = ({
235238

236239
return (
237240
<Page>
238-
{/* // TODO: IMPLEMENT PAGEMETADATA */}
239-
{/* <PageMetadata
241+
<PageMetadata
240242
title={frontmatter.title}
241243
description={frontmatter.description}
242-
/> */}
244+
/>
243245
<SideNavMobile path={relativePath} />
244246
{isPageIncomplete && (
245247
<BannerNotification shouldShow={isPageIncomplete}>
@@ -248,7 +250,7 @@ export const DocsLayout = ({
248250
)}
249251
<ContentContainer>
250252
<SideNav path={relativePath} />
251-
<Content>
253+
<Content id={MAIN_CONTENT_ID}>
252254
<H1 id="top">{frontmatter.title}</H1>
253255
{useGitHubContributors ? (
254256
<GitHubContributors

src/layouts/Roadmap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const RoadmapLayout: React.FC<IProps> = ({
190190
maxDepth={frontmatter.sidebarDepth!}
191191
tocItems={tocItems}
192192
/>
193-
<ContentContainer id="content">
193+
<ContentContainer>
194194
{children}
195195
<FeedbackCard />
196196
</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: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import UpcomingEventsList from "@/components/UpcomingEventsList"
3030

3131
import { getLocaleTimestamp } from "@/lib/utils/time"
3232

33-
import { CONTENT_DIR } from "@/lib/constants"
33+
import { CONTENT_DIR, MAIN_CONTENT_ID } from "@/lib/constants"
3434

3535
const Heading1 = (props: HeadingProps) => (
3636
<MdHeading1 fontSize={{ base: "2.5rem", md: "5xl" }} {...props} />
@@ -103,6 +103,7 @@ export const StaticLayout: React.FC<IProps> = ({
103103
>
104104
<Box
105105
as="article"
106+
id={MAIN_CONTENT_ID}
106107
maxW="container.md"
107108
w="full"
108109
sx={{
@@ -121,9 +122,7 @@ export const StaticLayout: React.FC<IProps> = ({
121122
}}
122123
>
123124
<Breadcrumbs slug={slug} mb="8" />
124-
<Text
125-
color="text200"
126-
>
125+
<Text color="text200">
127126
<Translation id="page-last-updated" />:{" "}
128127
{getLocaleTimestamp(locale as Lang, lastUpdatedDate!)}
129128
</Text>

src/layouts/Tutorial.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {
1616
import type { ChildOnlyProp, TranslationKey } from "@/lib/types"
1717
import type { MdPageContent, TutorialFrontmatter } from "@/lib/interfaces"
1818

19-
// TODO: Import once intl implements?
20-
// import PageMetadata from "@/components/PageMetadata"
2119
import PostMergeBanner from "@/components/Banners/PostMergeBanner"
22-
// Components
2320
import { ButtonLink } from "@/components/Buttons"
2421
import CallToContribute from "@/components/CallToContribute"
2522
import Card from "@/components/Card"
@@ -38,12 +35,17 @@ import {
3835
Heading4 as MdHeading4,
3936
} from "@/components/MdComponents"
4037
import MdLink from "@/components/MdLink"
38+
import PageMetadata from "@/components/PageMetadata"
4139
import { mdxTableComponents } from "@/components/Table"
4240
import TableOfContents from "@/components/TableOfContents"
4341
import TutorialMetadata from "@/components/TutorialMetadata"
4442
import YouTube from "@/components/YouTube"
4543

46-
import { DEFAULT_LOCALE, EDIT_CONTENT_URL } from "@/lib/constants"
44+
import {
45+
DEFAULT_LOCALE,
46+
EDIT_CONTENT_URL,
47+
MAIN_CONTENT_ID,
48+
} from "@/lib/constants"
4749

4850
import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"
4951

@@ -211,13 +213,12 @@ export const TutorialLayout = ({
211213
p={{ base: "0", lg: "0 2rem 0 0" }}
212214
background={{ base: "background.base", lg: "ednBackground" }}
213215
>
214-
{/* TODO: Implement PageMetaData after intl */}
215-
{/* <PageMetadata
216+
<PageMetadata
216217
title={frontmatter.title}
217218
description={frontmatter.description}
218219
canonicalUrl={frontmatter.sourceUrl}
219-
/> */}
220-
<ContentContainer>
220+
/>
221+
<ContentContainer id={MAIN_CONTENT_ID}>
221222
<Heading1>{frontmatter.title}</Heading1>
222223
<TutorialMetadata frontmatter={frontmatter} timeToRead={timeToRead} />
223224
<TableOfContents

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import TableOfContents from "@/components/TableOfContents"
3333

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

36+
import { MAIN_CONTENT_ID } from "@/lib/constants"
37+
3638
const HeroContainer = (props: ChildOnlyProp) => (
3739
<Flex
3840
bg="cardGradient"
@@ -235,7 +237,7 @@ export const UseCasesLayout: React.FC<IProps> = ({
235237
<Show above={lgBp}>
236238
<Flex
237239
as={BaseLink}
238-
to="#content"
240+
to={"#" + MAIN_CONTENT_ID}
239241
bg="ednBackground"
240242
justifyContent="center"
241243
p={4}
@@ -255,7 +257,7 @@ export const UseCasesLayout: React.FC<IProps> = ({
255257
tocItems={tocItems}
256258
maxDepth={frontmatter.sidebarDepth!}
257259
/>
258-
<ContentContainer id="content">
260+
<ContentContainer>
259261
{children}
260262
<FeedbackCard />
261263
</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

2324
// Config
2425
export const CONTENT_IMAGES_MAX_WIDTH = 800

0 commit comments

Comments
 (0)