@rimelight/ui 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/package.json +9 -8
- package/src/components/Head.astro +153 -150
- package/src/components/astro/RLAHeader.astro +75 -75
- package/src/composables/useUi.ts +2 -2
- package/src/env.d.ts +13 -16
- package/src/integrations/ui.ts +21 -10
- package/src/integrations/vue-entrypoint.ts +6 -0
- package/src/middleware/sri.ts +2 -2
- package/src/nuxt.ts +125 -0
- package/src/styles/index.css +2 -0
- package/src/utils/index.ts +0 -2
- package/src/components/BlogPost.astro +0 -181
- package/src/components/DynamicShowcase.astro +0 -681
- package/src/components/ExtendedCarousel.astro +0 -107
- package/src/components/FormattedDate.astro +0 -22
- package/src/components/HeaderLink.astro +0 -24
- package/src/components/LanguageSwitcher.astro +0 -128
- package/src/components/MissingTranslationBanner.astro +0 -39
- package/src/components/ProjectPost.astro +0 -183
- package/src/components/RLHead.astro +0 -3
- package/src/utils/deep-merge.ts +0 -36
- package/src/utils/parse-boolean.ts +0 -14
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import Carousel from "@rimelight/ui/components/carousel/Carousel.astro";
|
|
3
|
-
import CarouselPrevious from "@rimelight/ui/components/carousel/CarouselPrevious.astro";
|
|
4
|
-
import CarouselNext from "@rimelight/ui/components/carousel/CarouselNext.astro";
|
|
5
|
-
import type { HTMLAttributes } from "astro/types";
|
|
6
|
-
import type { EmblaOptionsType } from "embla-carousel";
|
|
7
|
-
|
|
8
|
-
export interface ExtendedCarouselProps extends HTMLAttributes<"div"> {
|
|
9
|
-
opts?: EmblaOptionsType;
|
|
10
|
-
orientation?: "horizontal" | "vertical";
|
|
11
|
-
showDots?: boolean;
|
|
12
|
-
}
|
|
13
|
-
type Props = ExtendedCarouselProps;
|
|
14
|
-
|
|
15
|
-
const { opts = {}, orientation = "horizontal", showDots = true, class: className, ...rest } = Astro.props;
|
|
16
|
-
|
|
17
|
-
// Default loop to true for ExtendedCarousel
|
|
18
|
-
const carouselOpts: EmblaOptionsType = {
|
|
19
|
-
loop: true,
|
|
20
|
-
...opts
|
|
21
|
-
};
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
<Carousel
|
|
25
|
-
opts={carouselOpts}
|
|
26
|
-
orientation={orientation}
|
|
27
|
-
class:list={["extended-carousel group/extended-carousel", className]}
|
|
28
|
-
{...rest}
|
|
29
|
-
data-extended-carousel
|
|
30
|
-
autoInit={false}
|
|
31
|
-
>
|
|
32
|
-
<slot />
|
|
33
|
-
|
|
34
|
-
<div class="hidden md:block">
|
|
35
|
-
<CarouselPrevious class="-left-12 opacity-50 hover:opacity-100 transition-opacity" />
|
|
36
|
-
<CarouselNext class="-right-12 opacity-50 hover:opacity-100 transition-opacity" />
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
{showDots && (
|
|
40
|
-
<div class="carousel-pagination absolute bottom-8 left-1/2 -translate-x-1/2 z-10 flex justify-center items-center gap-1.5" data-slot="pagination">
|
|
41
|
-
{/* Dots injected by script */}
|
|
42
|
-
</div>
|
|
43
|
-
)}
|
|
44
|
-
</Carousel>
|
|
45
|
-
|
|
46
|
-
<script>
|
|
47
|
-
import { initCarousel } from "@rimelight/ui/components/carousel/carousel-script.ts";
|
|
48
|
-
|
|
49
|
-
const setupExtendedCarousels = () => {
|
|
50
|
-
const extendedCarousels = document.querySelectorAll('[data-extended-carousel]') as NodeListOf<HTMLElement>;
|
|
51
|
-
|
|
52
|
-
extendedCarousels.forEach((carousel) => {
|
|
53
|
-
// Avoid double-initialization
|
|
54
|
-
if (carousel.dataset.extendedInitialized === "true") return;
|
|
55
|
-
carousel.dataset.extendedInitialized = "true";
|
|
56
|
-
|
|
57
|
-
// Initialize the underlying Starwind carousel
|
|
58
|
-
// Passing autoInit={false} to the component means we handle init here
|
|
59
|
-
const manager = initCarousel(carousel);
|
|
60
|
-
if (!manager) return;
|
|
61
|
-
|
|
62
|
-
const api = manager.api;
|
|
63
|
-
const pagination = carousel.querySelector('[data-slot="pagination"]');
|
|
64
|
-
|
|
65
|
-
if (pagination) {
|
|
66
|
-
const scrollSnaps = api.scrollSnapList();
|
|
67
|
-
const dots: HTMLButtonElement[] = [];
|
|
68
|
-
|
|
69
|
-
// Clear existing (useful for handle re-init cases)
|
|
70
|
-
pagination.innerHTML = '';
|
|
71
|
-
|
|
72
|
-
scrollSnaps.forEach((_: number, index: number) => {
|
|
73
|
-
const dot = document.createElement('button');
|
|
74
|
-
dot.className = 'size-4 rounded-full bg-border transition-all hover:bg-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary h-4 cursor-pointer';
|
|
75
|
-
dot.setAttribute('aria-label', `Go to slide ${index + 1}`);
|
|
76
|
-
dot.addEventListener('click', () => api.scrollTo(index));
|
|
77
|
-
pagination.appendChild(dot);
|
|
78
|
-
dots.push(dot);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const updateDots = () => {
|
|
82
|
-
const selectedIndex = api.selectedScrollSnap();
|
|
83
|
-
dots.forEach((dot, index) => {
|
|
84
|
-
if (index === selectedIndex) {
|
|
85
|
-
dot.classList.add('bg-primary');
|
|
86
|
-
dot.classList.remove('bg-border');
|
|
87
|
-
} else {
|
|
88
|
-
dot.classList.remove('bg-primary');
|
|
89
|
-
dot.classList.add('bg-border');
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
api.on('select', updateDots);
|
|
95
|
-
api.on('init', updateDots);
|
|
96
|
-
api.on('reInit', updateDots);
|
|
97
|
-
|
|
98
|
-
updateDots();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// Run on load and after Astro page swaps
|
|
104
|
-
document.addEventListener("DOMContentLoaded", setupExtendedCarousels);
|
|
105
|
-
document.addEventListener("astro:after-swap", setupExtendedCarousels);
|
|
106
|
-
</script>
|
|
107
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
export interface FormattedDateProps {
|
|
3
|
-
date?: Date | undefined;
|
|
4
|
-
}
|
|
5
|
-
type Props = FormattedDateProps;
|
|
6
|
-
|
|
7
|
-
const { date } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
date && (
|
|
12
|
-
<time datetime={date.toISOString()}>
|
|
13
|
-
{
|
|
14
|
-
date.toLocaleDateString('en-us', {
|
|
15
|
-
year: 'numeric',
|
|
16
|
-
month: 'short',
|
|
17
|
-
day: 'numeric',
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
</time>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from 'astro/types';
|
|
3
|
-
|
|
4
|
-
export interface HeaderLinkProps extends HTMLAttributes<"a"> {}
|
|
5
|
-
type Props = HeaderLinkProps;
|
|
6
|
-
|
|
7
|
-
const { href, class: className, ...props } = Astro.props;
|
|
8
|
-
const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, '');
|
|
9
|
-
const subpath = pathname.match(/[^/]+/g);
|
|
10
|
-
const isActive = href === pathname || href === '/' + (subpath?.[0] || '');
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
<a
|
|
14
|
-
href={href}
|
|
15
|
-
class:list={[
|
|
16
|
-
className,
|
|
17
|
-
"inline-block no-underline",
|
|
18
|
-
{ "font-bold underline active": isActive }
|
|
19
|
-
]}
|
|
20
|
-
{...props}
|
|
21
|
-
>
|
|
22
|
-
<slot />
|
|
23
|
-
</a>
|
|
24
|
-
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
/**
|
|
3
|
-
* Language Switcher Component (Extension)
|
|
4
|
-
*
|
|
5
|
-
* Variants:
|
|
6
|
-
* - 'full': Shows language icon, current flag, name, and chevron
|
|
7
|
-
* - 'label' (default): Shows language icon and current flag only
|
|
8
|
-
*
|
|
9
|
-
* Uses Starwind components for consistency.
|
|
10
|
-
* Built using native Astro i18n features.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import Dropdown from "@rimelight/ui/components/dropdown/Dropdown.astro";
|
|
14
|
-
import DropdownTrigger from "@rimelight/ui/components/dropdown/DropdownTrigger.astro";
|
|
15
|
-
import DropdownContent from "@rimelight/ui/components/dropdown/DropdownContent.astro";
|
|
16
|
-
import DropdownItem from "@rimelight/ui/components/dropdown/DropdownItem.astro";
|
|
17
|
-
import Button from "@rimelight/ui/components/button/Button.astro";
|
|
18
|
-
import Flag from "@rimelight/ui/components/icons/Flag.astro";
|
|
19
|
-
|
|
20
|
-
import { SUPPORTED_LOCALES, LANGUAGES } from "@rimelight/ui/domain";
|
|
21
|
-
import { localeToFlagCode } from "@rimelight/ui/domain";
|
|
22
|
-
import { replaceLocaleInPath } from "@rimelight/ui/domain";
|
|
23
|
-
import type { Locale } from "@rimelight/ui/domain";
|
|
24
|
-
|
|
25
|
-
export interface LanguageSwitcherProps {
|
|
26
|
-
variant?: 'full' | 'label';
|
|
27
|
-
class?: string;
|
|
28
|
-
}
|
|
29
|
-
type Props = LanguageSwitcherProps;
|
|
30
|
-
|
|
31
|
-
const { variant = 'label', class: className } = Astro.props;
|
|
32
|
-
const { uiLocale: currentLocale } = Astro.locals;
|
|
33
|
-
const currentPath = Astro.url.pathname;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Utility to compute the target URL for a locale switch
|
|
37
|
-
* Handles standard Astro routing by replacing the locale prefix in the URL.
|
|
38
|
-
*/
|
|
39
|
-
function getSwitchUrl(targetLocale: string) {
|
|
40
|
-
return replaceLocaleInPath(currentPath, currentLocale as string, targetLocale);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const currentFlagCode = localeToFlagCode(currentLocale as Locale);
|
|
44
|
-
const currentLabel = LANGUAGES[(currentLocale as Locale) as keyof typeof LANGUAGES] || currentLocale;
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
<Dropdown class={className}>
|
|
48
|
-
<DropdownTrigger asChild>
|
|
49
|
-
<Button
|
|
50
|
-
variant="outline"
|
|
51
|
-
size="sm"
|
|
52
|
-
class:list={[
|
|
53
|
-
"rounded-full border-border/50 bg-background/50 hover:bg-background transition-all h-9 shadow-none",
|
|
54
|
-
variant === 'full' ? "px-3xs" : "px-5xs",
|
|
55
|
-
]}
|
|
56
|
-
aria-label="Select Language"
|
|
57
|
-
>
|
|
58
|
-
<div class="flex items-center gap-5xs">
|
|
59
|
-
<div class="flex items-center justify-center shrink-0 opacity-70 size-4.5">
|
|
60
|
-
<svg
|
|
61
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
62
|
-
class="text-current size-4.5"
|
|
63
|
-
viewBox="0 0 24 24"
|
|
64
|
-
fill="none"
|
|
65
|
-
stroke="currentColor"
|
|
66
|
-
stroke-width="2"
|
|
67
|
-
stroke-linecap="round"
|
|
68
|
-
stroke-linejoin="round"
|
|
69
|
-
>
|
|
70
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 5h7" /><path d="M9 3v2c0 4.418 -2.239 8 -5 8" /><path d="M5 9c0 2.144 2.952 3.908 6.7 4" /><path d="M12 20l4 -9l4 9" /><path d="M19.1 18h-6.2" />
|
|
71
|
-
</svg>
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
<div class="flex items-center -translate-y-[0.5px]">
|
|
75
|
-
<Flag code={currentFlagCode} size={18} class="rounded-sm shadow-sm border border-border/20" />
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
{variant === 'full' && (
|
|
79
|
-
<div class="flex items-center gap-5xs border-l border-border/30 pl-5xs ml-3xs">
|
|
80
|
-
<span class="text-xs font-medium text-muted-foreground whitespace-nowrap leading-none flex items-center translate-y-[0.5px]">
|
|
81
|
-
{currentLabel}
|
|
82
|
-
</span>
|
|
83
|
-
<div class="flex items-center justify-center opacity-50 -translate-y-[0.5px]">
|
|
84
|
-
<svg class="size-3.5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
|
85
|
-
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
|
|
86
|
-
</svg>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
</Button>
|
|
92
|
-
</DropdownTrigger>
|
|
93
|
-
|
|
94
|
-
<DropdownContent align="end" class="w-6xl border-border/50 bg-background/95 backdrop-blur-md p-5xs">
|
|
95
|
-
{SUPPORTED_LOCALES.map((locale) => {
|
|
96
|
-
const isActive = locale === currentLocale;
|
|
97
|
-
const href = getSwitchUrl(locale);
|
|
98
|
-
const flagCode = localeToFlagCode(locale as Locale);
|
|
99
|
-
const label = LANGUAGES[(locale as Locale) as keyof typeof LANGUAGES] || locale;
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<DropdownItem
|
|
103
|
-
as="a"
|
|
104
|
-
href={href}
|
|
105
|
-
class:list={[
|
|
106
|
-
"flex items-center h-10 px-3xs gap-3xs transition-colors rounded-lg",
|
|
107
|
-
isActive ? "bg-accent/70 text-foreground font-semibold" : "text-muted-foreground hover:text-foreground"
|
|
108
|
-
]}
|
|
109
|
-
>
|
|
110
|
-
<div class="flex items-center shrink-0 -translate-y-[0.5px]">
|
|
111
|
-
<Flag code={flagCode} size={18} class="rounded-sm shadow-sm border border-border/20" />
|
|
112
|
-
</div>
|
|
113
|
-
<span class="text-sm leading-none flex items-center translate-y-[0.5px]">{label}</span>
|
|
114
|
-
{isActive && (
|
|
115
|
-
<div class="ml-auto flex items-center justify-center h-full text-primary">
|
|
116
|
-
<svg class="size-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
|
117
|
-
<path fill-rule="evenodd" d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z" clip-rule="evenodd" />
|
|
118
|
-
</svg>
|
|
119
|
-
</div>
|
|
120
|
-
)}
|
|
121
|
-
</DropdownItem>
|
|
122
|
-
);
|
|
123
|
-
})}
|
|
124
|
-
|
|
125
|
-
</DropdownContent>
|
|
126
|
-
</Dropdown>
|
|
127
|
-
|
|
128
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { checkMissingTranslation } from '../domain/i18n/resolve-locale'
|
|
3
|
-
import { fetchTranslations } from '../domain/i18n/fetcher'
|
|
4
|
-
|
|
5
|
-
export interface MissingTranslationBannerProps {}
|
|
6
|
-
type Props = MissingTranslationBannerProps;
|
|
7
|
-
|
|
8
|
-
const missingType = checkMissingTranslation(
|
|
9
|
-
Astro.locals.uiLocale,
|
|
10
|
-
Astro.locals.isMissingContent
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
let bannerText: string | null = null
|
|
14
|
-
|
|
15
|
-
if (missingType) {
|
|
16
|
-
const { cfContext, translationLocale } = Astro.locals
|
|
17
|
-
const runtime = { cf: Astro.request.cf, cfContext }
|
|
18
|
-
const { messages } = await fetchTranslations(
|
|
19
|
-
runtime,
|
|
20
|
-
translationLocale,
|
|
21
|
-
['messages']
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
bannerText =
|
|
25
|
-
missingType === 'content'
|
|
26
|
-
? messages.errors.ui.MISSING_TRANSLATED_CONTENT ||
|
|
27
|
-
'Sorry, this article is not yet available in your selected language.'
|
|
28
|
-
: messages.errors.ui.MISSING_TRANSLATED_UI ||
|
|
29
|
-
'Sorry, this page is not yet fully available in your selected language.'
|
|
30
|
-
}
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
bannerText && (
|
|
35
|
-
<div class='rounded px-4 py-2 mb-8 max-w-160 mx-auto border border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-600 dark:bg-amber-900/20 dark:text-amber-600 text-center'>
|
|
36
|
-
{bannerText}
|
|
37
|
-
</div>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { Image } from "astro:assets";
|
|
3
|
-
import { scv } from "css-variants";
|
|
4
|
-
import type { CollectionEntry } from "astro:content";
|
|
5
|
-
import Separator from "@rimelight/ui/components/separator/Separator.astro";
|
|
6
|
-
import Avatar from "@rimelight/ui/components/avatar/Avatar.astro";
|
|
7
|
-
import AvatarImage from "@rimelight/ui/components/avatar/AvatarImage.astro";
|
|
8
|
-
import avatarAsset from "../assets/team/Daniel-Marchi_0000_00.webp";
|
|
9
|
-
import { fetchTranslations } from "@rimelight/ui/domain";
|
|
10
|
-
|
|
11
|
-
const { translationLocale, cfContext } = Astro.locals;
|
|
12
|
-
const runtime = { cf: Astro.request.cf, cfContext };
|
|
13
|
-
const { projects: t } = await fetchTranslations(runtime, translationLocale, ["projects"]);
|
|
14
|
-
|
|
15
|
-
// Support both Astro content collections and CMS documents
|
|
16
|
-
export type CMSProjectDocument = {
|
|
17
|
-
_id: string;
|
|
18
|
-
slug?: string;
|
|
19
|
-
title: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
heroImage?: string;
|
|
22
|
-
publishedDate?: string | Date | null;
|
|
23
|
-
featured?: boolean;
|
|
24
|
-
tags?: string[] | Record<string, unknown> | null;
|
|
25
|
-
_updatedAt?: string;
|
|
26
|
-
_createdAt?: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export interface ProjectPostProps extends NonNullable<Parameters<typeof projectPostVariants>[0]> {
|
|
30
|
-
project: CollectionEntry<"projects"> | CMSProjectDocument;
|
|
31
|
-
class?: string;
|
|
32
|
-
showImage?: boolean;
|
|
33
|
-
separator?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Props = ProjectPostProps;
|
|
37
|
-
|
|
38
|
-
const projectPostVariants = scv({
|
|
39
|
-
slots: [
|
|
40
|
-
"root",
|
|
41
|
-
"imageWrapper",
|
|
42
|
-
"image",
|
|
43
|
-
"content",
|
|
44
|
-
"title",
|
|
45
|
-
"description",
|
|
46
|
-
"footer",
|
|
47
|
-
"authorGroup",
|
|
48
|
-
"author",
|
|
49
|
-
"link",
|
|
50
|
-
"badge",
|
|
51
|
-
"featuredBadge"
|
|
52
|
-
],
|
|
53
|
-
base: {
|
|
54
|
-
root: "group flex transition-all duration-300 w-full",
|
|
55
|
-
imageWrapper: "relative overflow-hidden ring-1 ring-border shadow-sm shrink-0 bg-muted isolate",
|
|
56
|
-
image: "absolute inset-0 h-full w-full !object-cover transition-transform duration-500 group-hover:scale-105 block",
|
|
57
|
-
content: "flex flex-col flex-1",
|
|
58
|
-
title: "font-heading font-bold tracking-tight text-pretty group-hover:text-primary transition-colors",
|
|
59
|
-
description: "text-muted-foreground line-clamp-2 text-base text-pretty",
|
|
60
|
-
footer: "mt-auto flex items-end justify-end w-full",
|
|
61
|
-
authorGroup: "flex flex-col gap-5xs text-xs font-medium text-muted-foreground",
|
|
62
|
-
author: "font-bold text-foreground",
|
|
63
|
-
link: "inline-flex items-center gap-5xs text-sm font-semibold hover:underline decoration-primary underline-offset-4",
|
|
64
|
-
badge: "px-2xs py-6xs rounded-full bg-muted text-muted-foreground text-[10px] font-bold uppercase tracking-wider",
|
|
65
|
-
featuredBadge: "absolute top-3 left-3 z-20 flex items-center gap-5xs px-3xs py-5xs rounded-full bg-primary text-primary-foreground text-[10px] font-bold uppercase tracking-wider shadow-lg ring-1 ring-white/20",
|
|
66
|
-
},
|
|
67
|
-
variants: {
|
|
68
|
-
variant: {
|
|
69
|
-
flat: {
|
|
70
|
-
root: "flex-col md:flex-row gap-3xl md:gap-4xl items-stretch py-4xl first:pt-0 last:pb-0 text-left",
|
|
71
|
-
imageWrapper: "w-full md:w-5/12 aspect-video self-stretch rounded-3xl shrink-0 shadow-none ring-0",
|
|
72
|
-
content: "gap-2xl justify-center items-start text-left",
|
|
73
|
-
title: "text-xl",
|
|
74
|
-
description: "text-base",
|
|
75
|
-
},
|
|
76
|
-
card: {
|
|
77
|
-
root: "flex-col bg-muted/20 p-2xl rounded-3xl border border-border/50 hover:bg-muted/40 hover:shadow-2xl hover:-translate-y-1 gap-2xl text-left items-stretch",
|
|
78
|
-
imageWrapper: "w-full aspect-video rounded-2xl shadow-lg",
|
|
79
|
-
title: "text-xl",
|
|
80
|
-
content: "gap-2xl text-left items-start",
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
defaultVariants: {
|
|
85
|
-
variant: "flat",
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const { project, variant, class: className, showImage = true, separator = false } = Astro.props;
|
|
90
|
-
|
|
91
|
-
// Detect if this is a CMS document or Astro content entry
|
|
92
|
-
const isCMSDocument = "_id" in project && !("id" in project);
|
|
93
|
-
|
|
94
|
-
// Extract fields based on source type
|
|
95
|
-
const projectTitle = isCMSDocument ? project.title : project.data.title;
|
|
96
|
-
const projectDescription = isCMSDocument ? project.description : project.data.description;
|
|
97
|
-
const projectImage = isCMSDocument ? project.heroImage : project.data.heroImage;
|
|
98
|
-
const projectFeatured = isCMSDocument ? (project.featured ?? false) : project.data.featured;
|
|
99
|
-
const projectTags = isCMSDocument ? (project.tags || []) : (project.data.tags || []);
|
|
100
|
-
|
|
101
|
-
// Handle date formatting
|
|
102
|
-
const rawDate = isCMSDocument ? (project.publishedDate || project._createdAt) : project.data.publishedDate;
|
|
103
|
-
const d = rawDate ? new Date(rawDate) : null;
|
|
104
|
-
const formattedDate = d && !isNaN(d.getTime())
|
|
105
|
-
? new Intl.DateTimeFormat(translationLocale, {
|
|
106
|
-
dateStyle: "medium",
|
|
107
|
-
}).format(d)
|
|
108
|
-
: "";
|
|
109
|
-
|
|
110
|
-
// Get slug from CMS or Astro content
|
|
111
|
-
const projectSlug = isCMSDocument
|
|
112
|
-
? (project.slug || "")
|
|
113
|
-
: project.id.replace(/^(en|pt|de|es|ja)\//, "");
|
|
114
|
-
|
|
115
|
-
const { root, imageWrapper, image, content, title, description, footer, authorGroup, author, link, badge, featuredBadge } = projectPostVariants({ variant });
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
<div class="flex flex-col w-full">
|
|
119
|
-
<a href={`/${translationLocale}/projects/${projectSlug}`} class:list={[root, className]}>
|
|
120
|
-
{showImage && (
|
|
121
|
-
<div class={imageWrapper}>
|
|
122
|
-
{projectFeatured && (
|
|
123
|
-
<div class={featuredBadge}>
|
|
124
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>
|
|
125
|
-
{t.latest_badge}
|
|
126
|
-
</div>
|
|
127
|
-
)}
|
|
128
|
-
{projectImage && (
|
|
129
|
-
<Image
|
|
130
|
-
src={projectImage as any}
|
|
131
|
-
alt={projectTitle}
|
|
132
|
-
width={800}
|
|
133
|
-
height={450}
|
|
134
|
-
class={image}
|
|
135
|
-
loading="lazy"
|
|
136
|
-
decoding="async"
|
|
137
|
-
/>
|
|
138
|
-
)}
|
|
139
|
-
</div>
|
|
140
|
-
)}
|
|
141
|
-
|
|
142
|
-
<div class={content}>
|
|
143
|
-
<h3 class={title}>
|
|
144
|
-
{projectTitle}
|
|
145
|
-
</h3>
|
|
146
|
-
|
|
147
|
-
<div class="flex items-center gap-3xs mt-3xs">
|
|
148
|
-
<Avatar size="sm" variant="primary">
|
|
149
|
-
<AvatarImage image={avatarAsset} alt="Daniel Marchi" />
|
|
150
|
-
</Avatar>
|
|
151
|
-
<div class={authorGroup}>
|
|
152
|
-
<span class={author}>Daniel Marchi</span>
|
|
153
|
-
<div class="flex items-center gap-3xs">
|
|
154
|
-
<span>{formattedDate}</span>
|
|
155
|
-
<div class="flex flex-wrap gap-5xs ml-3xs">
|
|
156
|
-
{Array.isArray(projectTags) && projectTags.map((tag: string) => (
|
|
157
|
-
<span class={badge}>{tag}</span>
|
|
158
|
-
))}
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
|
|
164
|
-
<p class={description}>
|
|
165
|
-
{projectDescription}
|
|
166
|
-
</p>
|
|
167
|
-
|
|
168
|
-
<div class={footer}>
|
|
169
|
-
<span class={link}>
|
|
170
|
-
{t.view_project}
|
|
171
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="transition-transform group-hover:translate-x-1"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg>
|
|
172
|
-
</span>
|
|
173
|
-
</div>
|
|
174
|
-
</div>
|
|
175
|
-
</a>
|
|
176
|
-
|
|
177
|
-
{separator && (
|
|
178
|
-
<div class="py-4xl last:hidden">
|
|
179
|
-
<Separator />
|
|
180
|
-
</div>
|
|
181
|
-
)}
|
|
182
|
-
</div>
|
|
183
|
-
|
package/src/utils/deep-merge.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
function isObject(value: unknown): value is Record<string, unknown> {
|
|
2
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Deep-merge two dictionaries. - `base` provides known structure (fallback) - `overrides` can
|
|
7
|
-
* provide partial values - Both types are preserved and merged correctly
|
|
8
|
-
*/
|
|
9
|
-
function assertRecord(obj: unknown): asserts obj is Record<string, unknown> {
|
|
10
|
-
if (!obj || typeof obj !== "object") throw new Error("Expected object")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function assertA<T>(obj: unknown): asserts obj is T {
|
|
14
|
-
if (!obj) throw new Error("Expected result")
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function deepMerge<A extends object, B extends Partial<A>>(base: A, overrides: B): A {
|
|
18
|
-
const result = { ...base }
|
|
19
|
-
assertRecord(result)
|
|
20
|
-
|
|
21
|
-
for (const key of Object.keys(overrides)) {
|
|
22
|
-
const overrideValue = Reflect.get(overrides, key)
|
|
23
|
-
const baseValue = Reflect.get(base, key)
|
|
24
|
-
|
|
25
|
-
if (overrideValue === undefined) continue
|
|
26
|
-
|
|
27
|
-
if (isObject(baseValue) && isObject(overrideValue)) {
|
|
28
|
-
Reflect.set(result, key, deepMerge(baseValue as object, overrideValue as Partial<object>))
|
|
29
|
-
} else {
|
|
30
|
-
Reflect.set(result, key, overrideValue)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
assertA<A>(result)
|
|
35
|
-
return result
|
|
36
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parse a boolean flag from Wrangler-env string.
|
|
3
|
-
*
|
|
4
|
-
* Accepts: "1", "true", "on" → true "0", "false", "off" → false undefined → defaultValue
|
|
5
|
-
*/
|
|
6
|
-
export function parseBooleanFlag(value: string | undefined, defaultValue: boolean): boolean {
|
|
7
|
-
if (value === undefined) return defaultValue
|
|
8
|
-
|
|
9
|
-
const v = value.toLowerCase()
|
|
10
|
-
if (v === "1" || v === "true" || v === "on") return true
|
|
11
|
-
if (v === "0" || v === "false" || v === "off") return false
|
|
12
|
-
|
|
13
|
-
return defaultValue
|
|
14
|
-
}
|