@easy-web/content-blocks 1.3.3 → 1.4.1
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/README.md +10 -395
- package/dist/schemas/galleries.d.ts +3 -316
- package/dist/schemas/galleries.d.ts.map +1 -1
- package/dist/schemas/galleries.js +3 -133
- package/dist/schemas/galleries.js.map +1 -1
- package/dist/schemas/notFound.d.ts +3 -32
- package/dist/schemas/notFound.d.ts.map +1 -1
- package/dist/schemas/notFound.js +3 -27
- package/dist/schemas/notFound.js.map +1 -1
- package/package.json +3 -4
- package/src/components/BlogPostCard.astro +8 -74
- package/src/components/Card.astro +8 -65
- package/src/components/CardGrid.astro +8 -24
- package/src/components/ContactSection.astro +8 -68
- package/src/components/CtaSection.astro +8 -77
- package/src/components/DraftBanner.astro +8 -28
- package/src/components/Footer.astro +8 -76
- package/src/components/GalleryCarousel.astro +9 -292
- package/src/components/GalleryFeatureHighlight.astro +9 -149
- package/src/components/GalleryHeroSlider.astro +9 -358
- package/src/components/GalleryImageGrid.astro +9 -139
- package/src/components/GalleryLightboxGrid.astro +9 -349
- package/src/components/GalleryMasonryGrid.astro +9 -123
- package/src/components/GallerySection.astro +9 -65
- package/src/components/Header.astro +13 -217
- package/src/components/HeaderCentered.astro +17 -242
- package/src/components/HeaderFlyout.astro +13 -380
- package/src/components/HeaderHideOnScroll.astro +17 -248
- package/src/components/Hero.astro +8 -73
- package/src/components/LanguageNotice.astro +8 -27
- package/src/components/LanguageSwitch.astro +7 -65
- package/src/components/LegalLayout.astro +8 -57
- package/src/components/NotFound.astro +7 -118
- package/src/components/PageShell.astro +7 -79
- package/src/components/Prose.astro +10 -153
- package/src/components/Section.astro +8 -32
- package/src/components/ThemeToggle.astro +8 -77
- package/src/components/UniversalMedia.astro +7 -96
- package/src/schemas/galleries.ts +3 -150
- package/src/schemas/notFound.ts +3 -31
- package/dist/__tests__/exports-resolution.test.d.ts +0 -2
- package/dist/__tests__/exports-resolution.test.d.ts.map +0 -1
- package/dist/__tests__/exports-resolution.test.js +0 -83
- package/dist/__tests__/exports-resolution.test.js.map +0 -1
- package/dist/components/__tests__/UniversalMedia.test.d.ts +0 -2
- package/dist/components/__tests__/UniversalMedia.test.d.ts.map +0 -1
- package/dist/components/__tests__/UniversalMedia.test.js +0 -46
- package/dist/components/__tests__/UniversalMedia.test.js.map +0 -1
- package/dist/schemas/__tests__/notFound.test.d.ts +0 -2
- package/dist/schemas/__tests__/notFound.test.d.ts.map +0 -1
- package/dist/schemas/__tests__/notFound.test.js +0 -29
- package/dist/schemas/__tests__/notFound.test.js.map +0 -1
- package/src/components/__tests__/UniversalMedia.test.ts +0 -65
- package/src/schemas/__tests__/notFound.test.ts +0 -32
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import type { ImageMetadata } from 'astro';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Mirrors the dispatch logic inside UniversalMedia.astro.
|
|
6
|
-
* Tests the categorisation, not the Astro rendering (which requires a full Astro setup).
|
|
7
|
-
*
|
|
8
|
-
* The component branches on 4 cases:
|
|
9
|
-
* 1. ImageMetadata object → <Image> (Astro-optimised)
|
|
10
|
-
* 2. "/src/assets/..." string → glob lookup → <Image> (with fallback path)
|
|
11
|
-
* 3. "http(s)://..." string → <Image inferSize>
|
|
12
|
-
* 4. Everything else (public path) → plain <img>
|
|
13
|
-
*/
|
|
14
|
-
type DispatchCase = 'image-metadata' | 'internal-src-assets' | 'external-url' | 'public-path';
|
|
15
|
-
|
|
16
|
-
function classifySource(src: ImageMetadata | string): DispatchCase {
|
|
17
|
-
if (typeof src !== 'string') return 'image-metadata';
|
|
18
|
-
if (src.startsWith('/src/assets/')) return 'internal-src-assets';
|
|
19
|
-
if (src.startsWith('http://') || src.startsWith('https://')) return 'external-url';
|
|
20
|
-
return 'public-path';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Minimal ImageMetadata stub for test case 1
|
|
24
|
-
const mockImageMetadata: ImageMetadata = {
|
|
25
|
-
src: '/src/assets/images/test.png',
|
|
26
|
-
width: 100,
|
|
27
|
-
height: 100,
|
|
28
|
-
format: 'png',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
describe('<UniversalMedia> dispatch logic', () => {
|
|
32
|
-
it('case 1: ImageMetadata object → image-metadata', () => {
|
|
33
|
-
expect(classifySource(mockImageMetadata)).toBe('image-metadata');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('case 2: /src/assets/ string → internal-src-assets (glob lookup path)', () => {
|
|
37
|
-
expect(classifySource('/src/assets/images/photo.jpg')).toBe('internal-src-assets');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('case 3: https:// URL → external-url (inferSize path)', () => {
|
|
41
|
-
expect(classifySource('https://example.com/photo.jpg')).toBe('external-url');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('case 4: public path /foo/bar.png → public-path (plain img)', () => {
|
|
45
|
-
expect(classifySource('/uploads/photo.jpg')).toBe('public-path');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('case 5: glob miss + fallbackSrc → fallback branch applies when resolvedSrc is null', () => {
|
|
49
|
-
// Simulate glob miss: empty images map for a /src/assets/ URL
|
|
50
|
-
const images: Record<string, () => Promise<{ default: ImageMetadata }>> = {};
|
|
51
|
-
const src = '/src/assets/images/missing.png';
|
|
52
|
-
const fallbackSrc = '/src/assets/images/default.png';
|
|
53
|
-
|
|
54
|
-
const dispatch = classifySource(src);
|
|
55
|
-
expect(dispatch).toBe('internal-src-assets');
|
|
56
|
-
|
|
57
|
-
// Verify fallback key lookup works
|
|
58
|
-
const hasMainImage = src in images;
|
|
59
|
-
const hasFallback = fallbackSrc in images;
|
|
60
|
-
expect(hasMainImage).toBe(false); // glob miss
|
|
61
|
-
expect(hasFallback).toBe(false); // fallback also missing → plain img fallback
|
|
62
|
-
|
|
63
|
-
// The component would render plain <img> when both are missing (documented in UniversalMedia)
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { notFoundSchema } from '../notFound.js';
|
|
3
|
-
|
|
4
|
-
describe('notFoundSchema', () => {
|
|
5
|
-
it('parses a multi-locale object with partial fields', () => {
|
|
6
|
-
const input = {
|
|
7
|
-
de: { heading: 'Seite nicht gefunden', message: 'Existiert nicht.' },
|
|
8
|
-
en: { heading: 'Not found' },
|
|
9
|
-
};
|
|
10
|
-
expect(() => notFoundSchema.parse(input)).not.toThrow();
|
|
11
|
-
const result = notFoundSchema.parse(input);
|
|
12
|
-
expect(result.de.heading).toBe('Seite nicht gefunden');
|
|
13
|
-
expect(result.en.heading).toBe('Not found');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('parses an empty object (all fields optional)', () => {
|
|
17
|
-
expect(() => notFoundSchema.parse({})).not.toThrow();
|
|
18
|
-
expect(notFoundSchema.parse({})).toEqual({});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('parses arbitrary locale keys (open record)', () => {
|
|
22
|
-
const input = { de: {}, fr: {}, sq: {} };
|
|
23
|
-
expect(() => notFoundSchema.parse(input)).not.toThrow();
|
|
24
|
-
const result = notFoundSchema.parse(input);
|
|
25
|
-
expect(Object.keys(result)).toEqual(expect.arrayContaining(['de', 'fr', 'sq']));
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('rejects a record where image is not a string', () => {
|
|
29
|
-
const input = { de: { image: 42 } };
|
|
30
|
-
expect(() => notFoundSchema.parse(input)).toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|