Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ const skipImageOptimization = process.env.SKIP_IMAGE_OPTIMIZATION === "true";
// https://astro.build/config
export default defineConfig({
output: isSSR ? "server" : "static",
adapter: isSSR
? (await import("@astrojs/node")).default({ mode: "standalone" })
: undefined,
...(isSSR
? {
adapter: (await import("@astrojs/node")).default({
mode: "standalone",
}),
}
: {}),
site: `https://${SITE_ROOTDOMAIN}`,
trailingSlash: "always",
markdown: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/blog/BlogCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props {
tags: string[];
title: string;
summary: string;
image?: ImageMetadata;
image?: ImageMetadata | undefined;
}

const { author, tags, title, summary, image, id } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/blog/BlogHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {
title: string;
id: string;
author: string;
tags?: string[];
tags?: string[] | undefined;
}

const { title, id, author, tags = [] } = Astro.props;
Expand Down
6 changes: 3 additions & 3 deletions src/components/pages/community/sponsorships/SponsorCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { ImageMetadata } from "astro";
interface Props {
name: string;
description: string;
href?: string;
logo?: ImageMetadata;
monochrome?: boolean;
href?: string | undefined;
logo?: ImageMetadata | undefined;
monochrome?: boolean | undefined;
}

const { name, description, href, logo, monochrome = false } = Astro.props;
Expand Down
16 changes: 12 additions & 4 deletions src/components/pages/downloads/CommunityCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface Props {
link: string;
linkText?: string;
translateTag?: (key: string) => string;
id?: string;
id?: string | undefined;
}

const {
Expand All @@ -42,7 +42,9 @@ const ALIAS: Record<string, string> = {
osx: "macos",
};

const ICONS: Record<string, ImageMetadata> = {
type PlatformKey = "windows" | "macos" | "linux" | "android" | "ios";

const ICONS: Record<PlatformKey, ImageMetadata> = {
windows: icons.mask("brand/windows"),
macos: icons.mask("brand/apple"),
linux: icons.mask("brand/linux"),
Expand All @@ -58,17 +60,23 @@ const LABEL: Record<string, string> = {
ios: t("downloads:platforms.ios") || "iOS",
};

const isPlatformKey = (key: string): key is PlatformKey => key in ICONS;

const VALID = {
desktop: new Set(["windows", "macos", "linux"]),
mobile: new Set(["android", "ios"]),
};

function normalizeKeys(arr: string[] | undefined, set: Set<string>) {
function normalizeKeys(
arr: string[] | undefined,
set: Set<string>,
): PlatformKey[] {
return Array.from(
new Set( // remove duplicates post-normalization
(arr ?? [])
.map((s) => ALIAS[norm(s)] ?? norm(s))
.filter((k) => set.has(k)),
.filter((k) => set.has(k))
.filter(isPlatformKey),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/downloads/CoreCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const {
} = Astro.props;
const { t, safeMarkdown } = Astro.locals;

const PLATFORM_ICONS: Record<string, ImageMetadata> = {
const PLATFORM_ICONS: Record<DownloadLink["platform"], ImageMetadata> = {
windows: icons.mask("brand/windows"),
macos: icons.mask("brand/apple"),
linux: icons.mask("brand/linux"),
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/resources/research-lab/PaperCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import Card from "@/components/ui/Card.astro";
import IconLink from "@/components/ui/IconLink.astro";

interface Props {
code?: string;
code?: string | undefined;
title: string;
abstract: string;
url: string;
note?: string;
note?: string | undefined;
}

const { code, title, abstract, url, note } = Astro.props;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Button.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Variant = "primary" | "secondary" | "outline" | "danger";
interface Props extends HTMLAttributes<As> {
variant?: Variant;
class?: string;
href?: string;
href?: string | undefined;
target?: string;
rel?: string;
as?: As;
Expand Down
6 changes: 3 additions & 3 deletions src/components/ui/ExternalResourceButton.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { icons } from "@/utils/icons";
export interface Props extends HTMLAttributes<"div"> {
href: string;
title: string;
subtitle?: string;
logo?: ImageMetadata;
onionHref?: string;
subtitle?: string | undefined;
logo?: ImageMetadata | undefined;
onionHref?: string | undefined;
variant?: "default" | "mini";
border?: boolean;
}
Expand Down
7 changes: 3 additions & 4 deletions src/components/ui/Paginator.astro
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ if (last <= 5) {
);
const sorted = [...visible].sort((a, b) => a - b);

for (let i = 0; i < sorted.length; i++) {
const n = sorted[i];
const prev = sorted[i - 1];
for (const [i, n] of sorted.entries()) {
const prev = i > 0 ? sorted[i - 1] : undefined;

// Add ellipsis or fill single gap
if (i > 0) {
if (prev !== undefined) {
const gap = n - prev;
if (gap === 2) {
items.push({ type: "page", number: prev + 1 });
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/accordion/AccordionItem.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Props {
title: string;
content?: string;
variant?: "default" | "card";
name?: string;
name?: string | undefined;
open?: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/dropdown/Dropdown.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { icons } from "@/utils/icons";

interface Props {
label?: string;
name?: string;
name?: string | undefined;
}
const { label, name } = Astro.props;
---
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/header/NavItem.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface DropdownItem {
href: string;
desc?: string;
icon: ImageMetadata;
iconDark?: ImageMetadata;
iconDark: ImageMetadata;
}

export interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/icons/MaskIcon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface Props {
src: ImageMetadata;
size?: number | string;
rtl?: boolean;
color?: string;
color?: string | undefined;
spacing?: string;
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface DropdownItem {
key: string;
href: string;
icon: ImageMetadata;
iconDark?: ImageMetadata;
iconDark: ImageMetadata;
}

interface NavDropdownConfig {
Expand Down
10 changes: 2 additions & 8 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,8 @@ const fullTitle = title.includes("|")
),
siteName: "Monero",
},
image: {
alt: openGraph?.image?.alt ?? undefined,
},
article: {
publishedTime: openGraph?.article?.publishedTime ?? undefined,
authors: openGraph?.article?.authors ?? undefined,
tags: openGraph?.article?.tags ?? undefined,
},
image: openGraph?.image ?? {},
article: openGraph?.article ?? {},
}}
languageAlternates={Object.keys(locales).map((lang) => ({
hrefLang: lang,
Expand Down
13 changes: 8 additions & 5 deletions src/pages/resources/press-kit.astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import { getPublicImageDimensions } from "@/utils/image";
import { icons } from "@/utils/icons";

const { t, localizeHref } = Astro.locals;
const previewDimensions = await Promise.all(
brandAssets.map((asset) => getPublicImageDimensions(asset.preview)),
const brandAssetPreviews = await Promise.all(
brandAssets.map(async (asset) => ({
asset,
preview: await getPublicImageDimensions(asset.preview),
})),
);

const sections = [
Expand Down Expand Up @@ -68,11 +71,11 @@ const sections = [
>
<Grid minWidth="22rem" gap="xl" class="assets-grid">
{
brandAssets.map((asset, i) => (
brandAssetPreviews.map(({ asset, preview }) => (
<BrandAssetCard
asset={asset}
previewWidth={previewDimensions[i].width}
previewHeight={previewDimensions[i].height}
previewWidth={preview.width}
previewHeight={preview.height}
/>
))
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/remark-moneropedia/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const moneropediaLinks: Plugin<[], Root> = () => {
);
} catch (error) {
console.error("[moneropedia] Processing error:", error);
return tree;
return;
}
};
};
6 changes: 6 additions & 0 deletions src/utils/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ export const idToDateSlug = (id: string): string => {
const [year, month, day, ...rest] = id.split("-");
const title = rest.join("-");

if (!year || !month || !day) {
throw new Error(
`Blog id "${id}" is not in the expected YYYY-MM-DD-title form.`,
);
}

return `${year}/${month.padStart(2, "0")}/${day.padStart(2, "0")}/${title}`;
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const icons = {
return m;
},

color(name: string): { light: ImageMetadata; dark?: ImageMetadata } {
color(name: string): { light: ImageMetadata; dark: ImageMetadata } {
const light = lightIcons[name] ?? colorRoot[name];
if (!light) throw new Error(`Unknown color icon: "${name}"`);
return { light, dark: darkIcons[name] ?? light };
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "astro/tsconfigs/strict",
"extends": "astro/tsconfigs/strictest",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"],
"compilerOptions": {
Expand Down
Loading