Tiny fixups
This commit is contained in:
parent
62a89706ec
commit
f94d6b24ab
|
@ -1,5 +1,5 @@
|
||||||
import type { WordingKey } from "src/i18n/wordings-keys";
|
import type { WordingKey } from "src/i18n/wordings-keys";
|
||||||
import type { ChronologyEvent, EndpointSource } from "src/shared/payload/payload-sdk";
|
import type { EndpointChronologyEvent, EndpointSource } from "src/shared/payload/payload-sdk";
|
||||||
import { contextCache } from "src/utils/payload";
|
import { contextCache } from "src/utils/payload";
|
||||||
import { capitalize, formatInlineTitle } from "src/utils/format";
|
import { capitalize, formatInlineTitle } from "src/utils/format";
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ export const getI18n = async (locale: string) => {
|
||||||
return number.toLocaleString(locale, options);
|
return number.toLocaleString(locale, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatTimelineDate = ({ year, month, day }: ChronologyEvent["date"]): string => {
|
const formatTimelineDate = ({ year, month, day }: EndpointChronologyEvent["date"]): string => {
|
||||||
const date = new Date(0);
|
const date = new Date(0);
|
||||||
date.setFullYear(year);
|
date.setFullYear(year);
|
||||||
if (month) date.setMonth(month - 1);
|
if (month) date.setMonth(month - 1);
|
||||||
|
|
|
@ -27,7 +27,7 @@ const {
|
||||||
height,
|
height,
|
||||||
} = image;
|
} = image;
|
||||||
|
|
||||||
const { getLocalizedMatch, formatDate, t, formatFilesize } = await getI18n(
|
const { getLocalizedMatch, formatDate, t, formatFilesize, formatNumber } = await getI18n(
|
||||||
Astro.locals.currentLocale
|
Astro.locals.currentLocale
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ const metaAttributes = [
|
||||||
{
|
{
|
||||||
title: t("global.media.attributes.resolution"),
|
title: t("global.media.attributes.resolution"),
|
||||||
icon: "material-symbols:photo-size-select-large",
|
icon: "material-symbols:photo-size-select-large",
|
||||||
values: [{ name: `${width} x ${height}` }],
|
values: [{ name: `${formatNumber(width)} x ${formatNumber(height)}` }],
|
||||||
withBorder: false,
|
withBorder: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,19 +143,25 @@ const { t, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
|
||||||
margin-top: 64px;
|
margin-top: 64px;
|
||||||
}
|
}
|
||||||
|
|
||||||
section {
|
section:not([hidden]) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
|
||||||
|
& > h2 {
|
||||||
|
margin-bottom: -12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > a {
|
||||||
|
width: fit-content
|
||||||
|
}
|
||||||
|
|
||||||
& > p {
|
& > p {
|
||||||
max-width: 35em;
|
max-width: 35em;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
margin-top: 12px;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&#library {
|
&#library {
|
||||||
& > a {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
& > .grid {
|
& > .grid {
|
||||||
@media (max-width: 40rem) {
|
@media (max-width: 40rem) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { getI18n } from "src/i18n/i18n";
|
import { getI18n } from "src/i18n/i18n";
|
||||||
import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk";
|
import type { EndpointChronologyEvent } from "src/shared/payload/payload-sdk";
|
||||||
import TimelineEventPartial from "../../api/timeline/partial.astro";
|
import TimelineEventPartial from "../../api/timeline/partial.astro";
|
||||||
|
import { formatTimelineDateToId } from "src/utils/format";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
event: EndpointChronologyEvent;
|
event: EndpointChronologyEvent;
|
||||||
|
@ -25,7 +26,7 @@ const multiple = displayDate && events.length > 1;
|
||||||
|
|
||||||
{/* ------------------------------------------- HTML ------------------------------------------- */}
|
{/* ------------------------------------------- HTML ------------------------------------------- */}
|
||||||
|
|
||||||
<div class="event-container">
|
<div class="event-container" id={formatTimelineDateToId(date)}>
|
||||||
{
|
{
|
||||||
displayDate && (
|
displayDate && (
|
||||||
<h3 class="font-xl" class:list={{ multiple }}>
|
<h3 class="font-xl" class:list={{ multiple }}>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
isNodeListNode,
|
isNodeListNode,
|
||||||
isNodeParagraphNode,
|
isNodeParagraphNode,
|
||||||
isNodeTextNode,
|
isNodeTextNode,
|
||||||
|
type EndpointChronologyEvent,
|
||||||
type RichTextContent,
|
type RichTextContent,
|
||||||
type RichTextNode,
|
type RichTextNode,
|
||||||
} from "src/shared/payload/payload-sdk";
|
} from "src/shared/payload/payload-sdk";
|
||||||
|
@ -53,3 +54,10 @@ export const capitalize = (string: string): string => {
|
||||||
if (firstLetter === undefined) return "";
|
if (firstLetter === undefined) return "";
|
||||||
return [firstLetter.toUpperCase(), ...otherLetters].join("");
|
return [firstLetter.toUpperCase(), ...otherLetters].join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const formatTimelineDateToId = (date: EndpointChronologyEvent["date"]): string => {
|
||||||
|
let result = date.year.toString();
|
||||||
|
if (date.month) result += `-${date.month.toString().padStart(2, "0")}`;
|
||||||
|
if (date.day) result += `-${date.day.toString().padStart(2, "0")}`;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue