Skip to content

Commit 954bb83

Browse files
committed
Fix the IntroTilePanel to use Docusaurus for link path resolution
1 parent 2e6922b commit 954bb83

8 files changed

Lines changed: 45 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build
1212
.env.development.local
1313
.env.test.local
1414
.env.production.local
15+
.idea
1516

1617
npm-debug.log*
1718
yarn-debug.log*

docs/introduction/intro-games.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Rocket from '@site/docs/assets/introduction/SpotIllustration_Rocket.webp'
55

66
# Games on Reddit
77

8-
Unleash your creativity and build engaging games inside Reddit communities with Devvit’s powerful platform. [Earn money](../earn-money/reddit_developer_funds) as players engage with your games.
8+
Unleash your creativity and build engaging games inside Reddit communities with Devvit’s powerful platform. [Earn money](../earn-money/reddit_developer_funds.md) as players engage with your games.
99

1010
Devvit is Reddit’s developer platform for building interactive, cross-platform games and apps that run natively on Reddit.
1111

@@ -26,7 +26,6 @@ Reddit is home to millions of communities, each with its own culture and interes
2626
{
2727
title: 'Quickstart',
2828
image: Rocket,
29-
href: '../quickstart',
3029
background: 'linear-gradient(135deg, #b2f7ef 0%, #4be18a 100%)',
3130
textColor: '#003820',
3231
imageSide: 'left',
@@ -36,15 +35,17 @@ Reddit is home to millions of communities, each with its own culture and interes
3635
{
3736
title: 'Showcase',
3837
image: Celebration,
39-
href: '../examples/app-showcase',
4038
background: 'linear-gradient(135deg, #ffe066 0%, #ff7c53 100%)',
4139
textColor: '#5a2a00',
4240
imageSide: 'right',
4341
textAlign: 'left',
4442
alt: 'Showcase',
4543
},
4644
]}
47-
/>
45+
>
46+
[Quickstart](../quickstart/quickstart.md)
47+
[Showcase](../examples/app-showcase.mdx)
48+
</IntroTilePanel>
4849

4950
<hr style={{ margin: '2.5rem 0', border: 'none', borderTop: '2px solid #eee' }} />
5051

docs/introduction/intro-mod-tools.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Devvit is Reddit’s developer platform for building interactive, cross-platform
2424
{
2525
title: 'Quickstart',
2626
image: Rocket,
27-
href: '../quickstart/quickstart-mod-tool',
2827
background: 'linear-gradient(135deg, #b2f7ef 0%, #4be18a 100%)',
2928
textColor: '#003820',
3029
imageSide: 'left',
@@ -34,15 +33,17 @@ Devvit is Reddit’s developer platform for building interactive, cross-platform
3433
{
3534
title: 'Mod Resources',
3635
image: SnooToolboxClipboard,
37-
href: '../guides/best-practices/mod_resources',
3836
background: 'linear-gradient(135deg, #ffe066 0%, #ff7c53 100%)',
3937
textColor: '#5a2a00',
4038
imageSide: 'right',
4139
textAlign: 'left',
4240
alt: 'Three Strikes Tutorial',
4341
},
4442
]}
45-
/>
43+
>
44+
[Quickstart](../quickstart/quickstart.md)
45+
[Mod Resources](../guides/best-practices/mod_resources.md)
46+
</IntroTilePanel>
4647

4748
<hr style={{ margin: '2.5rem 0', border: 'none', borderTop: '2px solid #eee' }} />
4849

docs/introduction/introduction.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Build community games like [Hot and Cold](https://www.reddit.com/r/hotandcold/),
4343
{
4444
title: 'Build Games',
4545
image: Rocket,
46-
href: './introduction/intro-games',
4746
background: 'linear-gradient(135deg, #b2f7ef 0%, #4be18a 100%)',
4847
textColor: '#003820',
4948
imageSide: 'left',
@@ -53,12 +52,14 @@ Build community games like [Hot and Cold](https://www.reddit.com/r/hotandcold/),
5352
{
5453
title: 'Create Mod Tools',
5554
image: SnooToolboxClipboard,
56-
href: './introduction/intro-mod-tools',
5755
background: 'linear-gradient(135deg, #ffe066 0%, #ff7c53 100%)',
5856
textColor: '#5a2a00',
5957
imageSide: 'right',
6058
textAlign: 'left',
6159
alt: 'Create Mod Tools',
6260
},
6361
]}
64-
/>
62+
>
63+
[Build Games](./intro-games.mdx)
64+
[Create Mod Tools](./intro-mod-tools.mdx)
65+
</IntroTilePanel>

src/components/IntroPagesFeatures/IntroTilePanel.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,23 @@ import React from 'react';
44
* IntroTilePanel - a reusable two-tile panel for intro pages.
55
* @param {Array} tiles - Array of tile configs: { image, alt, title, href, background, textColor, imageSide ('left'|'right'), ariaLabel }
66
* @param {string|number} gap - CSS gap between tiles (default: '2.5rem')
7+
* @param {ReactNode} children - Optional children to override tile hrefs via <a> elements
78
*/
8-
export default function IntroTilePanel({ tiles, gap = '2.5rem' }) {
9+
export default function IntroTilePanel({ tiles, gap = '2.5rem', children }) {
10+
// So, for the links we're given, we want to allow the user to override the hrefs via children <a> elements.
11+
// This allows MDX users to use relative links like [Learn More](./more) instead of hardcoding absolute URLs in the
12+
// tile config, which makes versioned docs work way better & prevents trailing slash issues from mattering.
13+
const titleToHRef = {};
14+
if(children) {
15+
for(const child of React.Children.toArray(children.props.children)) {
16+
// This works for both MDX <a> and regular <a> elements, as the browser will render both as <a>
17+
if(child?.type?.name === 'a' || child?.type?.name === 'MDXA') {
18+
const href = child.props.href;
19+
const title = child.props.children;
20+
titleToHRef[title] = href;
21+
}
22+
}
23+
}
924
return (
1025
<div style={{ padding: '0 2.5vw' }}>
1126
<div
@@ -18,12 +33,13 @@ export default function IntroTilePanel({ tiles, gap = '2.5rem' }) {
1833
alignItems: 'flex-start',
1934
}}
2035
>
21-
{tiles.map((tile, i) => {
36+
{tiles.map((tile) => {
2237
const isImageLeft = tile.imageSide === 'left';
38+
const href = titleToHRef[tile.title] ?? tile.href;
2339
return (
2440
<a
2541
key={tile.title}
26-
href={tile.href}
42+
href={href}
2743
style={{
2844
textDecoration: 'none',
2945
color: 'inherit',

versioned_docs/version-0.12/introduction/intro-games.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Reddit is home to millions of communities, each with its own culture and interes
2626
{
2727
title: 'Quickstart',
2828
image: Rocket,
29-
href: '../quickstart',
3029
background: 'linear-gradient(135deg, #b2f7ef 0%, #4be18a 100%)',
3130
textColor: '#003820',
3231
imageSide: 'left',
@@ -36,15 +35,17 @@ Reddit is home to millions of communities, each with its own culture and interes
3635
{
3736
title: 'Showcase',
3837
image: Celebration,
39-
href: '../examples/app-showcase',
4038
background: 'linear-gradient(135deg, #ffe066 0%, #ff7c53 100%)',
4139
textColor: '#5a2a00',
4240
imageSide: 'right',
4341
textAlign: 'left',
4442
alt: 'Showcase',
4543
},
4644
]}
47-
/>
45+
>
46+
[Quickstart](../quickstart/quickstart.md)
47+
[Showcase](../examples/app-showcase.mdx)
48+
</IntroTilePanel>
4849

4950
<hr style={{ margin: '2.5rem 0', border: 'none', borderTop: '2px solid #eee' }} />
5051

versioned_docs/version-0.12/introduction/intro-mod-tools.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Devvit is Reddit’s developer platform for building interactive, cross-platform
2424
{
2525
title: 'Quickstart',
2626
image: Rocket,
27-
href: '../quickstart/quickstart-mod-tool',
2827
background: 'linear-gradient(135deg, #b2f7ef 0%, #4be18a 100%)',
2928
textColor: '#003820',
3029
imageSide: 'left',
@@ -34,15 +33,17 @@ Devvit is Reddit’s developer platform for building interactive, cross-platform
3433
{
3534
title: 'Mod Resources',
3635
image: SnooToolboxClipboard,
37-
href: '../guides/best-practices/mod_resources',
3836
background: 'linear-gradient(135deg, #ffe066 0%, #ff7c53 100%)',
3937
textColor: '#5a2a00',
4038
imageSide: 'right',
4139
textAlign: 'left',
4240
alt: 'Three Strikes Tutorial',
4341
},
4442
]}
45-
/>
43+
>
44+
[Quickstart](../quickstart/quickstart.md)
45+
[Mod Resources](../guides/best-practices/mod_resources.md)
46+
</IntroTilePanel>
4647

4748
<hr style={{ margin: '2.5rem 0', border: 'none', borderTop: '2px solid #eee' }} />
4849

versioned_docs/version-0.12/introduction/introduction.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Build community games like [Hot and Cold](https://www.reddit.com/r/hotandcold/),
4343
{
4444
title: 'Build Games',
4545
image: Rocket,
46-
href: './introduction/intro-games',
4746
background: 'linear-gradient(135deg, #b2f7ef 0%, #4be18a 100%)',
4847
textColor: '#003820',
4948
imageSide: 'left',
@@ -53,12 +52,14 @@ Build community games like [Hot and Cold](https://www.reddit.com/r/hotandcold/),
5352
{
5453
title: 'Create Mod Tools',
5554
image: SnooToolboxClipboard,
56-
href: './introduction/intro-mod-tools',
5755
background: 'linear-gradient(135deg, #ffe066 0%, #ff7c53 100%)',
5856
textColor: '#5a2a00',
5957
imageSide: 'right',
6058
textAlign: 'left',
6159
alt: 'Create Mod Tools',
6260
},
6361
]}
64-
/>
62+
>
63+
[Build Games](./intro-games.mdx)
64+
[Create Mod Tools](./intro-mod-tools.mdx)
65+
</IntroTilePanel>

0 commit comments

Comments
 (0)