@easy-web/content-blocks 1.3.2 → 1.4.0

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.
Files changed (54) hide show
  1. package/README.md +10 -395
  2. package/dist/schemas/galleries.d.ts +3 -316
  3. package/dist/schemas/galleries.d.ts.map +1 -1
  4. package/dist/schemas/galleries.js +3 -133
  5. package/dist/schemas/galleries.js.map +1 -1
  6. package/dist/schemas/notFound.d.ts +3 -32
  7. package/dist/schemas/notFound.d.ts.map +1 -1
  8. package/dist/schemas/notFound.js +3 -27
  9. package/dist/schemas/notFound.js.map +1 -1
  10. package/package.json +3 -4
  11. package/src/components/BlogPostCard.astro +8 -74
  12. package/src/components/Card.astro +8 -65
  13. package/src/components/CardGrid.astro +8 -24
  14. package/src/components/ContactSection.astro +8 -68
  15. package/src/components/CtaSection.astro +8 -77
  16. package/src/components/DraftBanner.astro +8 -28
  17. package/src/components/Footer.astro +8 -76
  18. package/src/components/GalleryCarousel.astro +9 -292
  19. package/src/components/GalleryFeatureHighlight.astro +9 -149
  20. package/src/components/GalleryHeroSlider.astro +9 -358
  21. package/src/components/GalleryImageGrid.astro +9 -139
  22. package/src/components/GalleryLightboxGrid.astro +9 -349
  23. package/src/components/GalleryMasonryGrid.astro +9 -123
  24. package/src/components/GallerySection.astro +9 -65
  25. package/src/components/Header.astro +13 -217
  26. package/src/components/HeaderCentered.astro +17 -242
  27. package/src/components/HeaderFlyout.astro +13 -380
  28. package/src/components/HeaderHideOnScroll.astro +17 -248
  29. package/src/components/Hero.astro +8 -73
  30. package/src/components/LanguageNotice.astro +8 -27
  31. package/src/components/LanguageSwitch.astro +7 -65
  32. package/src/components/LegalLayout.astro +8 -48
  33. package/src/components/NotFound.astro +7 -118
  34. package/src/components/PageShell.astro +7 -79
  35. package/src/components/Prose.astro +10 -153
  36. package/src/components/Section.astro +8 -32
  37. package/src/components/ThemeToggle.astro +8 -77
  38. package/src/components/UniversalMedia.astro +7 -96
  39. package/src/schemas/galleries.ts +3 -150
  40. package/src/schemas/notFound.ts +3 -31
  41. package/dist/__tests__/exports-resolution.test.d.ts +0 -2
  42. package/dist/__tests__/exports-resolution.test.d.ts.map +0 -1
  43. package/dist/__tests__/exports-resolution.test.js +0 -83
  44. package/dist/__tests__/exports-resolution.test.js.map +0 -1
  45. package/dist/components/__tests__/UniversalMedia.test.d.ts +0 -2
  46. package/dist/components/__tests__/UniversalMedia.test.d.ts.map +0 -1
  47. package/dist/components/__tests__/UniversalMedia.test.js +0 -46
  48. package/dist/components/__tests__/UniversalMedia.test.js.map +0 -1
  49. package/dist/schemas/__tests__/notFound.test.d.ts +0 -2
  50. package/dist/schemas/__tests__/notFound.test.d.ts.map +0 -1
  51. package/dist/schemas/__tests__/notFound.test.js +0 -29
  52. package/dist/schemas/__tests__/notFound.test.js.map +0 -1
  53. package/src/components/__tests__/UniversalMedia.test.ts +0 -65
  54. 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
- });