Skip to content

Commit 52c1b7f

Browse files
authored
Merge pull request #2654 from plowsof/deterministic-dist-zip
remove non determinism from deployed site files [beta]
2 parents 97b67bd + ebdbe7a commit 52c1b7f

10 files changed

Lines changed: 32 additions & 13 deletions

File tree

src/components/ui/accordion/Accordion.astro

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
import "node:crypto";
3-
42
import AccordionItem from "./AccordionItem.astro";
53
64
export interface AccordionItemType {
@@ -15,7 +13,15 @@ export interface Props {
1513
}
1614
1715
const { items, multiExpand = false, variant = "default" } = Astro.props;
18-
const accordionId = crypto.randomUUID();
16+
if (items?.some((i) => typeof i.title !== "string" || !i.title.trim())) {
17+
throw new Error("<Accordion> item has an empty title.");
18+
}
19+
const accordionId = items?.length
20+
? `${variant}-${[...items.map((i) => i.title).join("")]
21+
.slice(0, 7)
22+
.map((c) => c.codePointAt(0))
23+
.join("-")}`
24+
: `${variant}-slot`;
1925
const accordionName = multiExpand ? undefined : `accordion-${accordionId}`;
2026
---
2127

src/components/ui/header/NavItem.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export interface Props {
2121
2222
const { label, href, dropdown = [] } = Astro.props;
2323
const isDropdown = dropdown.length > 0;
24-
const id = "dd-" + Math.random().toString(36).slice(2, 11);
24+
const id = `dd-${[...label]
25+
.slice(0, 7)
26+
.map((c) => c.codePointAt(0))
27+
.join("-")}`;
2528
const closeId = id + "-close";
2629
---
2730

src/components/ui/tabs/PageTabs.astro

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
2-
import crypto from "node:crypto";
3-
42
interface Props {
53
labels: string[]; // One label per panel slot (panel-0 ... panel-9)
64
links?: string[]; // Optional array of URLs, if provided, renders as navigation links instead of same-page tabs
7-
id?: string; // Optional stable id if multiple components on a page
5+
id: string; // Required id
86
initial?: number; // 0-based default tab
97
activeIndex?: number; // 0-based active tab for navigation mode
108
}
@@ -23,7 +21,10 @@ if (links && links.length !== labels.length) {
2321
if (links && labels.some((_, i) => Astro.slots.has(`panel-${i}`))) {
2422
throw new Error("<PageTabs> cannot have both links and slot content.");
2523
}
26-
const uid = id ?? `tabs-${crypto.randomUUID()}`;
24+
if (typeof id !== "string" || id.trim() === "") {
25+
throw new Error("<PageTabs> requires a non-empty id.");
26+
}
27+
const uid = id.trim();
2728
const I = (n: number) =>
2829
Math.min(Math.max(0, Number(n) || 0), labels.length - 1);
2930
const active = I(initial);

src/components/ui/tabs/SectionTabs.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
import crypto from "node:crypto";
3-
42
interface Tab {
53
label: string;
64
count?: number;
@@ -17,7 +15,10 @@ if (!tabs || tabs.length === 0) {
1715
throw new Error("<SectionTabs> requires at least one tab");
1816
}
1917
20-
const uid = `stabs-${crypto.randomUUID().slice(0, 8)}`;
18+
const uid = `stabs-${[...tabs.map((t) => t.label).join("")]
19+
.slice(0, 7)
20+
.map((c) => c.codePointAt(0))
21+
.join("-")}`;
2122
---
2223

2324
<div class:list={["section-tabs", className]} id={uid}>

src/pages/blog/[...page].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const tabs = [
6161
<PageContainer>
6262
<Row justify="between" align="center" wrap={false} class="tabs-bar">
6363
<PageTabs
64+
id="tabs-blog"
6465
labels={tabs.map((tab) => tab.label)}
6566
links={tabs.map((tab) => localizeHref(tab.link))}
6667
activeIndex={0}

src/pages/blog/tags/[tag]/[...page].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const titleKey = isMainTab ? "blog:index.hero.title" : "blog:tags.hero.title";
9292
<PageContainer>
9393
<Row justify="between" align="center" wrap={false} class="tabs-bar">
9494
<PageTabs
95+
id={`tabs-blog-tag-${tag}`}
9596
labels={tabs.map((tab) => tab.label)}
9697
links={tabs.map((tab) => localizeHref(tab.link))}
9798
activeIndex={activeTab}

src/pages/blog/tags/index.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import TitleCard from "@/components/ui/TitleCard.astro";
44
import Layout from "@/layouts/Layout.astro";
55
import { getCollection } from "astro:content";
66
7-
const allPosts = await getCollection("blog");
7+
const allPosts = (await getCollection("blog")).sort((a, b) =>
8+
a.id.localeCompare(b.id),
9+
);
810
const tags = [...new Set(allPosts.flatMap((post) => post.data.tags))].filter(
911
(tag) => tag !== undefined,
1012
);

src/pages/downloads/community.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const setBuiltinId = (wallet: Wallet) => {
8080
/>
8181
<PageContainer>
8282
<PageTabs
83+
id="tabs-downloads-community"
8384
labels={tabs.map((tab) => tab.label)}
8485
links={tabs.map((tab) => tab.link)}
8586
activeIndex={1}

src/pages/downloads/index.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const tabs = [
3838
/>
3939
<PageContainer>
4040
<PageTabs
41+
id="tabs-downloads-core"
4142
labels={tabs.map((tab) => tab.label)}
4243
links={tabs.map((tab) => tab.link)}
4344
activeIndex={0}

src/pages/feed.xml.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { createSafeMarkdown } from "@/utils/safeMarkdown";
66
const safeMarkdown = createSafeMarkdown();
77

88
export async function GET(context) {
9-
const blog = await getCollection("blog");
9+
const blog = (await getCollection("blog")).sort((a, b) =>
10+
b.id.localeCompare(a.id),
11+
);
1012
return rss({
1113
title: "Monero",
1214
description: "Monero Blog RSS Feed",

0 commit comments

Comments
 (0)