Skip to content

Commit 4f40cef

Browse files
darbyjackjpenilla
andauthored
MDX Improvements (#200)
* feat: contributors component for mdx * feat: initial mdx download button component * Add backup banner component, misc refinements * fix border inconsistency * Adjust DownloadButton news component, use it * Make news page layout closer match news index, add back link * Allow breaking words when wrapping news content if absolutely needed (very long words/phrases --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
1 parent cd45855 commit 4f40cef

27 files changed

+427
-144
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/assets/icons/lucide/rss.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/IconButton.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ export interface Props {
66
label: string;
77
href?: string;
88
external?: boolean;
9+
className?: string;
910
}
1011
11-
const { icon, label, href } = Astro.props;
12+
const { icon, label, href, className } = Astro.props;
1213
---
1314

1415
{
@@ -17,13 +18,13 @@ const { icon, label, href } = Astro.props;
1718
href={href}
1819
rel="noreferrer"
1920
target="_blank"
20-
class="inline-block h-min w-min rounded-full p-2 leading-0 transition-colors hover:bg-gray-800/20 dark:hover:bg-gray-400/20"
21+
class={`inline-block h-min w-min rounded-full p-2 leading-0 transition-colors hover:bg-gray-800/20 dark:hover:bg-gray-400/20 ${className}`}
2122
aria-label={label}
2223
>
2324
<Icon name={icon} class="size-6 text-gray-700 dark:text-gray-300" />
2425
</a>
2526
) : (
26-
<button class="h-min w-min rounded-full p-2 transition-colors hover:bg-gray-800/20" aria-label={label}>
27+
<button class={`h-min w-min rounded-full p-2 transition-colors hover:bg-gray-800/20 ${className}`} aria-label={label}>
2728
<img src={icon} class="gray-700 h-6 w-6" alt="" />
2829
</button>
2930
)

src/components/data/UserImage.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ interface Props {
55
avatarUrl: string;
66
name: string;
77
link?: string;
8+
class?: string;
89
}
9-
const { avatarUrl, name, link } = Astro.props;
10+
const { avatarUrl, name, link, class: extra } = Astro.props;
1011
const Tag = link ? "a" : "div";
1112
const initial = (name?.trim?.()[0] ?? "?").toUpperCase();
1213
---
1314

1415
<Tag
1516
role={link ? "button" : undefined}
16-
class="user-image relative flex aspect-square items-center justify-center overflow-hidden rounded-full bg-gray-600 font-bold text-white uppercase transition-transform hover:scale-105 hover:shadow-lg"
17+
class={`user-image relative flex aspect-square items-center justify-center overflow-hidden rounded-full bg-gray-600 font-bold text-white uppercase transition-transform hover:scale-103 active:translate-y-[0.5px] shadow-md active:shadow-none ${extra ?? ""}`}
1718
href={link}
1819
rel={link && "noreferrer"}
1920
target={link && "_blank"}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
import UserImage from "src/components/data/UserImage.astro";
3+
import GitHubIcon from "@/assets/icons/fontawesome/github-brands.svg";
4+
import PatreonIcon from "@/assets/icons/fontawesome/patreon-brands.svg";
5+
import PayPalIcon from "@/assets/icons/fontawesome/paypal-brands.svg";
6+
7+
type Contributor = {
8+
username: string;
9+
sponsor?: string;
10+
};
11+
12+
const { contributors = [] as Contributor[] } = Astro.props as {
13+
contributors?: Contributor[];
14+
};
15+
16+
const ghProfile = (u: string) => `https://github.com/${u}`;
17+
const ghAvatar = (u: string, size = 48) => `https://avatars.githubusercontent.com/${u}?size=${size}`;
18+
19+
type SponsorKind = "ghs" | "patreon" | "paypal" | "other";
20+
const sponsorKind = (url: string): SponsorKind => {
21+
if (url.includes("github.com/sponsors")) return "ghs";
22+
if (url.includes("patreon.com")) return "patreon";
23+
if (url.includes("paypal.me")) return "paypal";
24+
return "other";
25+
};
26+
27+
const sponsorMeta = (url: string) => {
28+
const kind = sponsorKind(url);
29+
const label = kind === "ghs" ? "GitHub Sponsors" : kind === "patreon" ? "Patreon" : kind === "paypal" ? "PayPal" : "Sponsor";
30+
return { kind, label } as const;
31+
};
32+
---
33+
34+
<ul
35+
class="bg-background-light-10 dark:bg-background-dark-90 contributors m-0 grid list-none grid-cols-1 gap-x-6 gap-y-3 rounded-md border p-3.5 sm:grid-cols-2 lg:grid-cols-4"
36+
>
37+
{
38+
contributors.map((c) => {
39+
const profile = ghProfile(c.username);
40+
const avatar = ghAvatar(c.username);
41+
const display = `@${c.username}`;
42+
43+
return (
44+
<li class="flex items-center gap-3">
45+
<UserImage avatarUrl={avatar} name={c.username} link={profile} class="size-11 sm:size-12" />
46+
47+
<div class="min-w-0">
48+
<a
49+
href={profile}
50+
target="_blank"
51+
rel="noopener noreferrer"
52+
class="text-sm font-medium text-slate-900 hover:underline dark:text-slate-100"
53+
>
54+
{display}
55+
</a>
56+
57+
{c.sponsor && (
58+
<div class="mt-0.5 flex items-center gap-1.5">
59+
<span class="text-xs text-slate-500 dark:text-slate-400">Sponsor:</span>
60+
{(() => {
61+
const { kind, label } = sponsorMeta(c.sponsor!);
62+
const baseClass = "size-4 fill-slate-500 dark:fill-slate-400";
63+
return (
64+
<a
65+
href={c.sponsor}
66+
target="_blank"
67+
rel="noopener noreferrer"
68+
aria-label={`${label} for ${display}`}
69+
title={label}
70+
class="inline-flex items-center text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200"
71+
>
72+
{kind === "ghs" ? (
73+
<GitHubIcon class={baseClass} />
74+
) : kind === "patreon" ? (
75+
<PatreonIcon class={baseClass} />
76+
) : kind === "paypal" ? (
77+
<PayPalIcon class={baseClass} />
78+
) : (
79+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
80+
<path
81+
d="M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20ZM2 12h20"
82+
stroke="currentColor"
83+
stroke-width="1.5"
84+
stroke-linecap="round"
85+
stroke-linejoin="round"
86+
/>
87+
</svg>
88+
)}
89+
</a>
90+
);
91+
})()}
92+
</div>
93+
)}
94+
</div>
95+
</li>
96+
);
97+
})
98+
}
99+
</ul>
100+
101+
<style>
102+
.contributors li {
103+
align-items: center;
104+
}
105+
</style>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
import DocumentDownloadIcon from "@/assets/icons/heroicons/document-download.svg";
3+
4+
interface Props {
5+
project: string;
6+
}
7+
8+
const { project } = Astro.props;
9+
10+
const href = "/downloads/" + project.toLowerCase();
11+
const label = "Download " + project;
12+
---
13+
14+
<a
15+
href={href}
16+
rel="noopener noreferrer"
17+
target="_blank"
18+
class="btn btn-primary group relative isolate mb-2 inline-flex w-full items-center justify-center gap-3 rounded-lg px-8 py-4 text-lg font-semibold sm:w-auto"
19+
>
20+
<DocumentDownloadIcon />
21+
22+
<span>{label}</span>
23+
</a>
24+
25+
<style>
26+
a {
27+
color: #ffffff;
28+
text-decoration: none;
29+
}
30+
</style>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
import { Icon } from "astro-icon/components";
3+
4+
interface Props {
5+
version: string;
6+
}
7+
8+
const { version } = Astro.props;
9+
---
10+
11+
<div class="border-danger bg-danger/30 flex gap-3.5 rounded-md border p-3.5">
12+
<Icon name="icons/lucide/octagon-alert" class="text-danger size-6 shrink-0" />
13+
<div>
14+
As always, <span class="font-semibold">backups are absolutely mandatory</span>. <span class="font-semibold"
15+
>After upgrading your world to {version}, you cannot downgrade back to a lower version!</span
16+
>
17+
</div>
18+
</div>

src/content/posts/1-21-3.mdx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ author: "Paper Team"
66

77
## The 1.21.3 Update
88

9-
Paper and Velocity 1.21.3 builds are out of the experimental phase! As always, **backups are absolutely mandatory**. **After upgrading your world to 1.21.3, you cannot downgrade back to a lower version!**
9+
Paper and Velocity 1.21.3 builds are out of the experimental phase!
10+
11+
<MandatoryBackups version="1.21.3" />
1012

1113
We would like to thank everyone that worked on this update:
1214

13-
- [Gerrygames](https://github.com/Gerrygames) for his work on Velocity
14-
- [@electronicboy](https://github.com/sponsors/electronicboy)
15-
- [@jmp](https://github.com/sponsors/jpenilla)
16-
- [kennytv](https://github.com/kennytv)
17-
- [Lulu13022002](https://github.com/Lulu13022002)
18-
- [@lynxplay](https://github.com/lynxplay)
19-
- [@Machine Maker](https://github.com/sponsors/Machine-Maker)
20-
- [@Noah](https://github.com/sponsors/NoahvdAa)
21-
- [@Owen1212055](https://github.com/sponsors/Owen1212055)
22-
- [SpaceWalkerRS](https://github.com/SpaceWalkerRS)
23-
- [@Spottedleaf](https://www.patreon.com/Spottedleaf)
15+
<Contributors
16+
contributors={[
17+
{ username: "Gerrygames" },
18+
{ username: "electronicboy", sponsor: "https://github.com/sponsors/electronicboy" },
19+
{ username: "jpenilla", sponsor: "https://github.com/sponsors/jpenilla" },
20+
{ username: "kennytv" },
21+
{ username: "Lulu13022002" },
22+
{ username: "lynxplay" },
23+
{ username: "Machine-Maker", sponsor: "https://github.com/sponsors/Machine-Maker" },
24+
{ username: "NoahvdAa", sponsor: "https://github.com/sponsors/NoahvdAa" },
25+
{ username: "Owen1212055", sponsor: "https://github.com/sponsors/Owen1212055" },
26+
{ username: "SpaceWalkerRS" },
27+
{ username: "Spottedleaf", sponsor: "https://www.patreon.com/Spottedleaf" },
28+
]}
29+
/>
2430

2531
If you'd like to support PaperMC as a whole, you can find more information at https://papermc.io/sponsors.
2632

@@ -93,3 +99,5 @@ itemStack.setData(DataComponentTypes.FOOD, food);
9399
- `EntityDamageEvent` now has the `INVULNERABILITY_REDUCTION` cause
94100
- Our auto-generated Vanilla key classes (e.g. `SoundEventKeys`) now implement `Key`, so they can be used in API like the data componenents API directly
95101
- You can now create custom painting art via API and the new `RegistryEvents.PAINTING_VARIANT`. More are coming over time as well - see https://docs.papermc.io/paper/dev/registries for more info on how to use them
102+
103+
<DownloadButton project="Paper" />

0 commit comments

Comments
 (0)