feat: glossary cron

This commit is contained in:
tresabhi committed 2025-04-19 00:47:28 -05:00
1 parent 365c68aa4d
commit c5e6f5e2eb
16 files changed
+367 -57

No files matched your search

@@ -1,9 +1,7 @@
import { literals } from '@blitzkit/i18n/src/literals';
import { CalendarIcon } from '@radix-ui/react-icons';
import { Callout, Flex } from '@radix-ui/themes';
import { GalleryList, type Avatar } from '../../../../components/Gallery/List';
import { GalleryList } from '../../../../components/Gallery/List';
import { GallerySearch } from '../../../../components/Gallery/Search';
import { PageWrapper } from '../../../../components/PageWrapper';
import { awaitableGallery } from '../../../../core/awaitables/gallery';
import {
LocaleProvider,
useLocale,
@@ -11,14 +9,8 @@ import {
} from '../../../../hooks/useLocale';
import { GalleryEphemeral } from '../../../../stores/galleryEphemeral';
interface ContentProps {
avatars: Avatar[];
lastUpdated: string;
}
type PageProps = ContentProps & LocaleAcceptorProps;
export function Page({ locale, ...props }: PageProps) {
export function Page({ locale, ...props }: LocaleAcceptorProps) {
return (
<LocaleProvider locale={locale}>
<Content {...props} />
@@ -26,27 +18,13 @@ export function Page({ locale, ...props }: PageProps) {
);
}
function Content({ avatars, lastUpdated }: ContentProps) {
const { strings } = useLocale();
function Content() {
return (
<PageWrapper maxWidth="80rem" color="gold">
<Flex justify="center">
<Callout.Root size="1">
<Callout.Icon>
<CalendarIcon />
</Callout.Icon>
<Callout.Text>
{literals(strings.website.tools.gallery.last_updated, [
lastUpdated,
])}
</Callout.Text>
</Callout.Root>
</Flex>
<GalleryEphemeral.Provider>
<GallerySearch />
<GalleryList avatars={avatars} />
<GalleryList />
</GalleryEphemeral.Provider>
</PageWrapper>
);
@@ -1,29 +1,15 @@
---
import type { Avatar } from '../../../../components/Gallery/List';
import { galleryTool } from '../../../../constants/tools';
import { fetchGlossary } from '../../../../core/blitz/fetchGlossary';
import ToolLayout from '../../../../layouts/ToolLayout.astro';
import { awaitableGallery } from '../../../../core/awaitables/gallery';
import ToolLayout from '../../../../layouts/ToolLayout.astro';
import { Page } from './_index';
export { getStaticPaths } from '../../index.astro';
const { locale } = Astro.params;
const glossary = await fetchGlossary(locale);
const avatars = Object.entries(glossary)
.filter(
([key, value]) =>
key.startsWith('avatar') &&
!key.endsWith('_part') &&
value.image_url !== null,
)
.map(
([key, value]) =>
({ id: key.replace('avatar_', ''), name: value.title }) satisfies Avatar,
)
.sort((a, b) => a.name.localeCompare(b.name));
const lastUpdated = new Date().toLocaleDateString(locale);
---
<ToolLayout tool={galleryTool}>
<Page {locale} {avatars} {lastUpdated} client:load />
<Page {locale} client:load />
</ToolLayout>