Skip to content

Commit ddedb41

Browse files
authored
Merge pull request #15451 from ethereum/fix-h-fonts
Fix layout component logic
2 parents a38b7d5 + f7c8dd4 commit ddedb41

File tree

14 files changed

+92
-60
lines changed

14 files changed

+92
-60
lines changed

app/[locale]/[...slug]/page.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import mdComponents from "@/components/MdComponents"
77

88
import { dataLoader } from "@/lib/utils/data/dataLoader"
99
import { dateToString } from "@/lib/utils/date"
10+
import { getLayoutFromSlug } from "@/lib/utils/layout"
1011
import { getPostSlugs } from "@/lib/utils/md"
1112
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
1213

@@ -19,18 +20,6 @@ import { getMdMetadata } from "@/lib/md/metadata"
1920

2021
const loadData = dataLoader([["gfissues", fetchGFIs]])
2122

22-
function getLayoutFromSlug(slug: string) {
23-
if (slug.includes("developers/docs")) {
24-
return "docs"
25-
}
26-
27-
if (slug.includes("developers/tutorials")) {
28-
return "tutorial"
29-
}
30-
31-
return "static"
32-
}
33-
3423
export default async function Page({
3524
params,
3625
}: {
@@ -69,7 +58,8 @@ export default async function Page({
6958
slug,
7059
// TODO: Address component typing error here (flip `FC` types to prop object types)
7160
// @ts-expect-error Incompatible component function signatures
72-
components: { ...mdComponents, ...componentsMapping },
61+
baseComponents: mdComponents,
62+
componentsMapping,
7363
scope: {
7464
gfissues,
7565
},

public/content/ai-agents/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ In contrast, Ethereum's decentralized ecosystem offers several key advantages:
3939

4040
These factors transform AI agents from simple bots into dynamic, self-improving systems that offer significant value across multiple sectors:
4141

42-
<CardGrid className="grid grid-cols-[repeat(auto-fill,_minmax(min(100%,_280px),_1fr))] gap-8">
42+
<CardGrid>
4343
<Card title="Automated DeFi" emoji=":money_with_wings:" description="AI agents keep a close eye on market trends, execute trades, and manage portfolios — making the complex world of DeFi a lot more approachable."/>
4444
<Card title="New AI agent economy" emoji="🌎" description="AI agents can hire other agents (or humans) with different skills to perform specialized tasks for them." />
4545
<Card title="Risk management" emoji="🛠️" description="By monitoring transactional activities, AI agents can help spot scams and safeguard your digital assets better and faster." />

public/content/payments/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This isn't a far-off dream – it's happening today on Ethereum. While tradition
2727

2828
For millions of people working abroad, sending money back home is a regular necessity. Traditional remittance services often come with high fees and slow processing times. Ethereum offers a compelling alternative.
2929

30-
<CardGrid className="grid grid-cols-[repeat(auto-fill,_minmax(min(100%,_280px),_1fr))] gap-8">
30+
<CardGrid>
3131
<Card title="Cheaper Fees" emoji=":money_with_wings:" description="Remittance services charge up to $14 fees on average. Ethereum transactions can often be completed under $0.01."/>
3232
<Card title="Faster Transfers" emoji="📶" description="International wire transfers take several days to process. Ethereum transactions are settled in minutes." />
3333
<Card title="Open to anyone" emoji="🌎" description="You only need an internet connection and a wallet app to send or receive Ether." />

public/content/prediction-markets/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In theory, because bettors stand to profit from being correct, prediction market
3030

3131
Unlike traditional forecasting, blockchain-based prediction markets are:
3232

33-
<CardGrid className="grid grid-cols-[repeat(auto-fill,_minmax(min(100%,_280px),_1fr))] gap-8">
33+
<CardGrid>
3434
<Card title="Incentivized" emoji=":money_with_wings:" description="Participants stake real funds, which infers high-quality predictions."/>
3535
<Card title="Decentralization" emoji="🌎" description="Using blockchain and smart contracts ensures transparent and automated payouts." />
3636
<Card title="Market driven odds" emoji="🤝" description="Prices are set by traders buying and selling outcome shares, rather than preset by a centralized bookmaker." />

src/components/ActionCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const ActionCard = ({
4141
return (
4242
<LinkBox
4343
className={cn(
44-
"flex flex-col md:flex-row shadow-table hover:scale-[1.02] hover:rounded hover:bg-background-highlight hover:shadow-table-box-hover hover:duration-100 focus:scale-[1.02] focus:rounded focus:shadow-table-box-hover focus:duration-100",
44+
"flex flex-col shadow-table hover:scale-[1.02] hover:rounded hover:bg-background-highlight hover:shadow-table-box-hover hover:duration-100 focus:scale-[1.02] focus:rounded focus:shadow-table-box-hover focus:duration-100 md:flex-row",
4545
className
4646
)}
4747
{...props}
@@ -57,7 +57,7 @@ const ActionCard = ({
5757
src={image}
5858
alt={alt || ""}
5959
width={imageWidth}
60-
className="max-h-full object-cover p-4 self-center"
60+
className="max-h-full self-center object-cover p-4"
6161
/>
6262
</Flex>
6363
<div className="flex flex-col justify-center p-6">

src/components/Codeblock.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ const TopBarItem = ({
4141

4242
const codeTheme = {
4343
light: {
44-
plain: {
45-
backgroundColor: "#f7f7f7", // background-highlight (gray-50)
46-
color: "#6C24DF", // primary (purple-600)
47-
},
4844
styles: [
4945
{
5046
style: { color: "#6c6783" },
@@ -113,10 +109,6 @@ const codeTheme = {
113109
},
114110
dark: {
115111
// Pulled from `defaultProps.theme` for potential customization
116-
plain: {
117-
backgroundColor: "#121212", // background-highlight (gray-900)
118-
color: "#B38DF0", // primary (purple-400)
119-
},
120112
styles: [
121113
{
122114
style: { color: "#6c6783" },
@@ -253,7 +245,7 @@ const Codeblock = ({
253245
/* Context: https://github.com/ethereum/ethereum-org-website/issues/6202 */
254246
<div className={cn("relative", className)} dir="ltr">
255247
<div
256-
className="overflow-scroll rounded"
248+
className="overflow-scroll rounded bg-background-highlight text-primary"
257249
style={{
258250
maxHeight: isCollapsed
259251
? `calc((1.2rem * ${LINES_BEFORE_COLLAPSABLE}) + 4.185rem)`

src/layouts/Docs.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MDXRemoteProps } from "next-mdx-remote"
12
import type { HTMLAttributes } from "react"
23

34
import { ChildOnlyProp } from "@/lib/types"
@@ -34,8 +35,7 @@ import YouTube from "@/components/YouTube"
3435
import { cn } from "@/lib/utils/cn"
3536
import { getEditPath } from "@/lib/utils/editPath"
3637

37-
const baseHeadingClasses =
38-
"font-mono uppercase font-bold scroll-mt-40 break-words"
38+
const baseHeadingClasses = "font-bold scroll-mt-40 break-words"
3939

4040
const H1 = (props: HTMLAttributes<HTMLHeadingElement>) => (
4141
<MdHeading1
@@ -72,12 +72,18 @@ const BackToTop = (props: ChildOnlyProp) => (
7272
</div>
7373
)
7474

75+
const Pre = (props: React.HTMLAttributes<HTMLDivElement>) => {
76+
const match = props.className?.match(/(language-\S+)/)
77+
const codeLanguage = match ? match[0] : "plain-text"
78+
return <Codeblock codeLanguage={codeLanguage} {...props} />
79+
}
80+
7581
export const docsComponents = {
7682
h1: H1,
7783
h2: H2,
7884
h3: H3,
7985
h4: H4,
80-
pre: Codeblock,
86+
pre: Pre,
8187
...mdxTableComponents,
8288
ButtonLink,
8389
Card,
@@ -88,7 +94,7 @@ export const docsComponents = {
8894
GlossaryTooltip,
8995
InfoBanner,
9096
YouTube,
91-
}
97+
} as MDXRemoteProps["components"]
9298

9399
type DocsLayoutProps = Pick<
94100
MdPageContent,

src/layouts/Tutorial.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MDXRemoteProps } from "next-mdx-remote"
12
import type { HTMLAttributes } from "react"
23

34
import type { ChildOnlyProp } from "@/lib/types"
@@ -28,17 +29,11 @@ import YouTube from "@/components/YouTube"
2829
import { getEditPath } from "@/lib/utils/editPath"
2930

3031
const Heading1 = (props: HTMLAttributes<HTMLHeadingElement>) => (
31-
<MdHeading1
32-
className="font-monospace uppercase max-lg:text-[1.75rem]"
33-
{...props}
34-
/>
32+
<MdHeading1 className="max-lg:text-[1.75rem]" {...props} />
3533
)
3634

3735
const Heading2 = (props: HTMLAttributes<HTMLHeadingElement>) => (
38-
<MdHeading2
39-
className="mt-12 scroll-mt-40 font-monospace uppercase max-md:text-2xl"
40-
{...props}
41-
/>
36+
<MdHeading2 className="mt-12 scroll-mt-40 max-md:text-2xl" {...props} />
4237
)
4338

4439
const Heading3 = (props: HTMLAttributes<HTMLHeadingElement>) => (
@@ -66,6 +61,12 @@ const KBD = (props: HTMLAttributes<HTMLElement>) => (
6661
/>
6762
)
6863

64+
const Pre = (props: React.HTMLAttributes<HTMLDivElement>) => {
65+
const match = props.className?.match(/(language-\S+)/)
66+
const codeLanguage = match ? match[0] : "plain-text"
67+
return <Codeblock codeLanguage={codeLanguage} {...props} />
68+
}
69+
6970
export const tutorialsComponents = {
7071
a: TooltipLink,
7172
h1: Heading1,
@@ -74,7 +75,7 @@ export const tutorialsComponents = {
7475
h4: Heading4,
7576
p: Paragraph,
7677
kbd: KBD,
77-
pre: Codeblock,
78+
pre: Pre,
7879
...mdxTableComponents,
7980
ButtonLink,
8081
CallToContribute,
@@ -83,7 +84,8 @@ export const tutorialsComponents = {
8384
EnvWarningBanner,
8485
InfoBanner,
8586
YouTube,
86-
}
87+
} as MDXRemoteProps["components"]
88+
8789
type TutorialLayoutProps = ChildOnlyProp &
8890
Pick<
8991
MdPageContent,

src/layouts/index.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { MDXRemoteProps } from "next-mdx-remote"
2+
3+
import { Layout } from "@/lib/types"
4+
15
import { docsComponents, DocsLayout } from "./Docs"
26
import * as mdLayouts from "./md"
37
import { staticComponents, StaticLayout } from "./Static"
@@ -20,13 +24,13 @@ export const layoutMapping = {
2024
tutorial: TutorialLayout,
2125
}
2226

23-
export const componentsMapping = {
24-
...staticComponents,
25-
...mdLayouts.useCasesComponents,
26-
...mdLayouts.stakingComponents,
27-
...mdLayouts.roadmapComponents,
28-
...mdLayouts.upgradeComponents,
29-
...mdLayouts.translatathonComponents,
30-
...docsComponents,
31-
...tutorialsComponents,
32-
} as const
27+
export const componentsMapping: Record<Layout, MDXRemoteProps["components"]> = {
28+
static: staticComponents,
29+
"use-cases": mdLayouts.useCasesComponents,
30+
staking: mdLayouts.stakingComponents,
31+
roadmap: mdLayouts.roadmapComponents,
32+
upgrade: mdLayouts.upgradeComponents,
33+
translatathon: mdLayouts.translatathonComponents,
34+
docs: docsComponents,
35+
tutorial: tutorialsComponents,
36+
}

src/layouts/md/Roadmap.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ import { ContentLayout } from "../ContentLayout"
1111
import { useTranslation } from "@/hooks/useTranslation"
1212
import RoadmapHubHeroImage from "@/public/images/heroes/roadmap-hub-hero.jpg"
1313

14-
const CardGrid = (props: ChildOnlyProp) => (
15-
<div className="grid grid-cols-1 gap-8 md:grid-cols-2" {...props} />
16-
)
17-
1814
// Roadmap layout components
1915
export const roadmapComponents = {
20-
CardGrid,
2116
RoadmapActionCard,
2217
RoadmapImageContent,
2318
}

0 commit comments

Comments
 (0)