@styleflow.app/flowpress-astro-core 1.0.0-beta.5 → 1.0.0-beta.50
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/CHANGELOG.md +307 -1
- package/README.md +121 -6
- package/dist/accessibility-panel.d.ts +2 -0
- package/dist/accessibility-panel.d.ts.map +1 -0
- package/dist/accessibility-panel.js +81 -0
- package/dist/accessibility-panel.js.map +1 -0
- package/dist/astro/BaseLayout.astro +34 -17
- package/dist/astro/CompositionRenderer.astro +170 -0
- package/dist/astro/DefaultBlockAdapter.astro +37 -0
- package/dist/astro/EditorialMedia.astro +47 -0
- package/dist/astro/FontStylesheets.astro +35 -0
- package/dist/astro/GutenbergRenderer.astro +270 -84
- package/dist/astro/Media.astro +27 -0
- package/dist/astro/StyleflowElement.astro +25 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +72 -101
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +158 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +5 -4
- package/dist/astro/blocks/HeroBlock.astro +6 -6
- package/dist/astro/blocks/ImageBlock.astro +6 -6
- package/dist/astro/blocks/ListItemFallback.astro +9 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +54 -0
- package/dist/astro/blocks/TextBlock.astro +33 -28
- package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
- package/dist/astro/blocks/cover.d.ts +13 -0
- package/dist/astro/blocks/cover.d.ts.map +1 -0
- package/dist/astro/blocks/cover.js +105 -0
- package/dist/astro/blocks/cover.js.map +1 -0
- package/dist/astro/blocks/cover.ts +119 -0
- package/dist/astro/blocks/helpers.d.ts +10 -1
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +55 -39
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +69 -44
- package/dist/astro/motion/AccordionRuntime.astro +9 -0
- package/dist/astro/motion/MotionBoot.astro +21 -0
- package/dist/astro/motion/MotionRuntime.astro +31 -0
- package/dist/astro/motion/accordion.css +163 -0
- package/dist/astro/motion/accordion.d.ts +3 -0
- package/dist/astro/motion/accordion.d.ts.map +1 -0
- package/dist/astro/motion/accordion.js +98 -0
- package/dist/astro/motion/accordion.js.map +1 -0
- package/dist/astro/motion/accordion.ts +109 -0
- package/dist/astro/motion/motion-controller.d.ts +12 -0
- package/dist/astro/motion/motion-controller.d.ts.map +1 -0
- package/dist/astro/motion/motion-controller.js +312 -0
- package/dist/astro/motion/motion-controller.js.map +1 -0
- package/dist/astro/motion/motion-controller.ts +393 -0
- package/dist/astro/motion/motion.css +600 -0
- package/dist/astro/motion/motion.d.ts +132 -0
- package/dist/astro/motion/motion.d.ts.map +1 -0
- package/dist/astro/motion/motion.js +265 -0
- package/dist/astro/motion/motion.js.map +1 -0
- package/dist/astro/motion/motion.ts +430 -0
- package/dist/astro/native/AccordionRuntime.astro +11 -0
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +88 -0
- package/dist/astro/native/LevelTag.astro +20 -0
- package/dist/astro/native/MapBlock.astro +41 -0
- package/dist/astro/native/NativeHtmlBlock.astro +12 -0
- package/dist/astro/native/NativeIconBlock.astro +42 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ReservedLogin.astro +107 -0
- package/dist/astro/native/ResolvedBlocks.astro +91 -0
- package/dist/astro/native/SyncedPatternContent.astro +94 -0
- package/dist/astro/native/TermFieldValue.astro +39 -0
- package/dist/astro/native/Timeline.astro +22 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/accordion-controller.d.ts +3 -0
- package/dist/astro/native/accordion-controller.d.ts.map +1 -0
- package/dist/astro/native/accordion-controller.js +143 -0
- package/dist/astro/native/accordion-controller.js.map +1 -0
- package/dist/astro/native/accordion-controller.ts +108 -0
- package/dist/astro/native/accordion.css +36 -0
- package/dist/astro/native/accordion.d.ts +24 -0
- package/dist/astro/native/accordion.d.ts.map +1 -0
- package/dist/astro/native/accordion.js +82 -0
- package/dist/astro/native/accordion.js.map +1 -0
- package/dist/astro/native/accordion.ts +91 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
- package/dist/astro/native/blob/config.d.ts +49 -0
- package/dist/astro/native/blob/config.d.ts.map +1 -0
- package/dist/astro/native/blob/config.js +86 -0
- package/dist/astro/native/blob/config.js.map +1 -0
- package/dist/astro/native/blob/config.ts +132 -0
- package/dist/astro/native/blob/controller.d.ts +11 -0
- package/dist/astro/native/blob/controller.d.ts.map +1 -0
- package/dist/astro/native/blob/controller.js +240 -0
- package/dist/astro/native/blob/controller.js.map +1 -0
- package/dist/astro/native/blob/controller.ts +248 -0
- package/dist/astro/native/blob/geometry.d.ts +2 -0
- package/dist/astro/native/blob/geometry.d.ts.map +1 -0
- package/dist/astro/native/blob/geometry.js +2 -0
- package/dist/astro/native/blob/geometry.js.map +1 -0
- package/dist/astro/native/blob/geometry.ts +1 -0
- package/dist/astro/native/blob/ids.d.ts +7 -0
- package/dist/astro/native/blob/ids.d.ts.map +1 -0
- package/dist/astro/native/blob/ids.js +11 -0
- package/dist/astro/native/blob/ids.js.map +1 -0
- package/dist/astro/native/blob/ids.ts +11 -0
- package/dist/astro/native/blob.css +83 -0
- package/dist/astro/native/block-sizing.css +34 -0
- package/dist/astro/native/button-template.d.ts +31 -0
- package/dist/astro/native/button-template.d.ts.map +1 -0
- package/dist/astro/native/button-template.js +54 -0
- package/dist/astro/native/button-template.js.map +1 -0
- package/dist/astro/native/button-template.ts +92 -0
- package/dist/astro/native/button.d.ts +13 -0
- package/dist/astro/native/button.d.ts.map +1 -0
- package/dist/astro/native/button.js +26 -0
- package/dist/astro/native/button.js.map +1 -0
- package/dist/astro/native/button.ts +26 -0
- package/dist/astro/native/carousel.css +323 -0
- package/dist/astro/native/core-accordion-heading.astro +23 -0
- package/dist/astro/native/core-accordion-item.astro +8 -0
- package/dist/astro/native/core-accordion-panel.astro +8 -0
- package/dist/astro/native/core-accordion.astro +8 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button-fallback.astro +43 -0
- package/dist/astro/native/core-button.astro +65 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +25 -0
- package/dist/astro/native/core-home-link.astro +12 -0
- package/dist/astro/native/core-html.astro +8 -0
- package/dist/astro/native/core-icon.astro +7 -0
- package/dist/astro/native/core-image.astro +136 -0
- package/dist/astro/native/core-navigation-link.astro +71 -0
- package/dist/astro/native/core-navigation-submenu.astro +33 -0
- package/dist/astro/native/core-navigation.astro +101 -0
- package/dist/astro/native/core-page-list-data-item.astro +19 -0
- package/dist/astro/native/core-page-list-item.astro +8 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +21 -0
- package/dist/astro/native/core-post-excerpt.astro +26 -0
- package/dist/astro/native/core-post-featured-image.astro +40 -0
- package/dist/astro/native/core-post-template-fallback.astro +30 -0
- package/dist/astro/native/core-post-template.astro +23 -0
- package/dist/astro/native/core-post-terms.astro +47 -0
- package/dist/astro/native/core-post-title.astro +23 -0
- package/dist/astro/native/core-query-no-results.astro +12 -0
- package/dist/astro/native/core-query.astro +22 -0
- package/dist/astro/native/core-separator.astro +18 -0
- package/dist/astro/native/core-site-title.astro +16 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +21 -0
- package/dist/astro/native/core-term-template.astro +30 -0
- package/dist/astro/native/core-terms-query.astro +19 -0
- package/dist/astro/native/core-transparent.astro +11 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.js +217 -0
- package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
- package/dist/astro/native/flowpress-navigation.css +18 -0
- package/dist/astro/native/grid-bleed.d.ts +2 -0
- package/dist/astro/native/grid-bleed.d.ts.map +1 -0
- package/dist/astro/native/grid-bleed.js +123 -0
- package/dist/astro/native/grid-bleed.js.map +1 -0
- package/dist/astro/native/grid.css +180 -0
- package/dist/astro/native/grid.d.ts +17 -0
- package/dist/astro/native/grid.d.ts.map +1 -0
- package/dist/astro/native/grid.js +108 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +132 -0
- package/dist/astro/native/group.css +36 -0
- package/dist/astro/native/group.d.ts +15 -0
- package/dist/astro/native/group.d.ts.map +1 -0
- package/dist/astro/native/group.js +66 -0
- package/dist/astro/native/group.js.map +1 -0
- package/dist/astro/native/group.ts +61 -0
- package/dist/astro/native/html.d.ts +6 -0
- package/dist/astro/native/html.d.ts.map +1 -0
- package/dist/astro/native/html.js +10 -0
- package/dist/astro/native/html.js.map +1 -0
- package/dist/astro/native/html.ts +9 -0
- package/dist/astro/native/icon.d.ts +3 -0
- package/dist/astro/native/icon.d.ts.map +1 -0
- package/dist/astro/native/icon.js +23 -0
- package/dist/astro/native/icon.js.map +1 -0
- package/dist/astro/native/icon.ts +21 -0
- package/dist/astro/native/image.d.ts +5 -0
- package/dist/astro/native/image.d.ts.map +1 -0
- package/dist/astro/native/image.js +65 -0
- package/dist/astro/native/image.js.map +1 -0
- package/dist/astro/native/image.ts +56 -0
- package/dist/astro/native/inline-text.css +15 -0
- package/dist/astro/native/map.d.ts +14 -0
- package/dist/astro/native/map.d.ts.map +1 -0
- package/dist/astro/native/map.js +60 -0
- package/dist/astro/native/map.js.map +1 -0
- package/dist/astro/native/map.ts +70 -0
- package/dist/astro/native/motion-preference.d.ts +50 -0
- package/dist/astro/native/motion-preference.d.ts.map +1 -0
- package/dist/astro/native/motion-preference.js +132 -0
- package/dist/astro/native/motion-preference.js.map +1 -0
- package/dist/astro/native/motion-preference.ts +158 -0
- package/dist/astro/native/motion.d.ts +101 -0
- package/dist/astro/native/motion.d.ts.map +1 -0
- package/dist/astro/native/motion.js +168 -0
- package/dist/astro/native/motion.js.map +1 -0
- package/dist/astro/native/motion.ts +312 -0
- package/dist/astro/native/query-carousel.d.ts +13 -0
- package/dist/astro/native/query-carousel.d.ts.map +1 -0
- package/dist/astro/native/query-carousel.js +36 -0
- package/dist/astro/native/query-carousel.js.map +1 -0
- package/dist/astro/native/query-carousel.ts +60 -0
- package/dist/astro/native/query-loop.d.ts +38 -0
- package/dist/astro/native/query-loop.d.ts.map +1 -0
- package/dist/astro/native/query-loop.js +20 -0
- package/dist/astro/native/query-loop.js.map +1 -0
- package/dist/astro/native/query-loop.ts +67 -0
- package/dist/astro/native/registry.d.ts +3 -0
- package/dist/astro/native/registry.d.ts.map +1 -0
- package/dist/astro/native/registry.js +91 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +93 -0
- package/dist/astro/native/sf-block-binding.astro +20 -0
- package/dist/astro/native/sf-post-field.astro +9 -0
- package/dist/astro/native/sf-slot.astro +6 -0
- package/dist/astro/native/sf-term-field.astro +9 -0
- package/dist/astro/native/timeline.css +4 -0
- package/dist/astro/native/timeline.d.ts +28 -0
- package/dist/astro/native/timeline.d.ts.map +1 -0
- package/dist/astro/native/timeline.js +43 -0
- package/dist/astro/native/timeline.js.map +1 -0
- package/dist/astro/native/timeline.ts +79 -0
- package/dist/astro/preferences/AccessibilityPanel.astro +105 -0
- package/dist/astro/preferences/ColorModeToggle.astro +26 -0
- package/dist/astro/preferences/MotionToggle.astro +27 -0
- package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
- package/dist/astro/preferences/ThemeToggle.astro +30 -0
- package/dist/astro/preferences/Toggle.astro +50 -0
- package/dist/astro/preferences/preferences.css +125 -0
- package/dist/block-renderers.d.ts +23 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/build-cache.d.ts +8 -0
- package/dist/build-cache.d.ts.map +1 -0
- package/dist/build-cache.js +82 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/carousel.d.ts +56 -6
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +183 -27
- package/dist/carousel.js.map +1 -1
- package/dist/client.d.ts +34 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -42
- package/dist/client.js.map +1 -1
- package/dist/composition.d.ts +14 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +125 -0
- package/dist/composition.js.map +1 -0
- package/dist/default-blocks.d.ts +9 -0
- package/dist/default-blocks.d.ts.map +1 -0
- package/dist/default-blocks.js +122 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +53 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +20 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +106 -0
- package/dist/media.js.map +1 -0
- package/dist/motion-preference.d.ts +50 -0
- package/dist/motion-preference.d.ts.map +1 -0
- package/dist/motion-preference.js +132 -0
- package/dist/motion-preference.js.map +1 -0
- package/dist/preferences-runtime.d.ts +3 -0
- package/dist/preferences-runtime.d.ts.map +1 -0
- package/dist/preferences-runtime.js +23 -0
- package/dist/preferences-runtime.js.map +1 -0
- package/dist/preferences-styleflow.d.ts +3 -0
- package/dist/preferences-styleflow.d.ts.map +1 -0
- package/dist/preferences-styleflow.js +14 -0
- package/dist/preferences-styleflow.js.map +1 -0
- package/dist/preferences.d.ts +4 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +4 -0
- package/dist/preferences.js.map +1 -0
- package/dist/reserved-area.d.ts +10 -0
- package/dist/reserved-area.d.ts.map +1 -0
- package/dist/reserved-area.js +93 -0
- package/dist/reserved-area.js.map +1 -0
- package/dist/styleflow.d.ts +18 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +82 -11
- package/dist/styleflow.js.map +1 -1
- package/dist/svg-media-runtime.d.ts +3 -0
- package/dist/svg-media-runtime.d.ts.map +1 -0
- package/dist/svg-media-runtime.js +33 -0
- package/dist/svg-media-runtime.js.map +1 -0
- package/dist/svg-media-types.d.ts +11 -0
- package/dist/svg-media-types.d.ts.map +1 -0
- package/dist/svg-media-types.js +2 -0
- package/dist/svg-media-types.js.map +1 -0
- package/dist/svg-media.d.ts +13 -0
- package/dist/svg-media.d.ts.map +1 -0
- package/dist/svg-media.js +47 -0
- package/dist/svg-media.js.map +1 -0
- package/dist/template-hierarchy.d.ts +0 -7
- package/dist/template-hierarchy.d.ts.map +1 -1
- package/dist/template-hierarchy.js +0 -21
- package/dist/template-hierarchy.js.map +1 -1
- package/dist/text.d.ts +3 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +6 -0
- package/dist/text.js.map +1 -0
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +100 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +75 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vivid-colors-preference.d.ts +31 -0
- package/dist/vivid-colors-preference.d.ts.map +1 -0
- package/dist/vivid-colors-preference.js +102 -0
- package/dist/vivid-colors-preference.js.map +1 -0
- package/package.json +58 -7
- package/dist/astro/DefaultTemplate.astro +0 -42
- package/dist/templates.d.ts +0 -19
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -20
- package/dist/templates.js.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Media from "../EditorialMedia.astro";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
import { imageMediaStyle } from "./image.js";
|
|
6
|
+
|
|
7
|
+
type ImageResolvedData = {
|
|
8
|
+
id?: number | undefined;
|
|
9
|
+
url?: string | undefined;
|
|
10
|
+
fullUrl?: string | undefined;
|
|
11
|
+
alt?: string | undefined;
|
|
12
|
+
width?: number | undefined;
|
|
13
|
+
height?: number | undefined;
|
|
14
|
+
srcSet?: string | undefined;
|
|
15
|
+
sizes?: string | undefined;
|
|
16
|
+
caption?: string | undefined;
|
|
17
|
+
figureClass?: string | undefined;
|
|
18
|
+
href?: string | undefined;
|
|
19
|
+
imageClass?: string | undefined;
|
|
20
|
+
linkClass?: string | undefined;
|
|
21
|
+
linkTarget?: string | undefined;
|
|
22
|
+
lightboxEnabled?: boolean | undefined;
|
|
23
|
+
rel?: string | undefined;
|
|
24
|
+
title?: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const { block, htmlProps, styleflowProps: rendererStyleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
28
|
+
const attributes = block.attributes;
|
|
29
|
+
const media = (block.resolvedData ?? {}) as ImageResolvedData;
|
|
30
|
+
// A native image is not a stack container. The semantic renderer supplies
|
|
31
|
+
// stack/regular defaults inside sf/* layouts, which override authored image
|
|
32
|
+
// utilities such as rounded-lg. Only apply layout coordinates it authors.
|
|
33
|
+
const { layoutRole: inheritedRole, density: inheritedDensity, ...remainingSemantic } = rendererStyleflowProps;
|
|
34
|
+
const styleflowProps = attributes.layoutRole ? rendererStyleflowProps : remainingSemantic;
|
|
35
|
+
|
|
36
|
+
function text(value: unknown): string {
|
|
37
|
+
return typeof value === "string" ? value.trim() : "";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function positiveInteger(value: unknown): number | undefined {
|
|
41
|
+
const match = String(value ?? "").trim().match(/^(\d+)(?:px)?$/);
|
|
42
|
+
const number = match ? Number(match[1]) : Number(value);
|
|
43
|
+
return Number.isInteger(number) && number > 0 ? number : undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function classNames(...values: unknown[]): string | undefined {
|
|
47
|
+
const className = [...new Set(
|
|
48
|
+
values
|
|
49
|
+
.flatMap((value) => String(value ?? "").split(/\s+/))
|
|
50
|
+
.filter(Boolean),
|
|
51
|
+
)].join(" ");
|
|
52
|
+
return className || undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const src = text(media.url) || text(attributes.url);
|
|
56
|
+
const id = positiveInteger(media.id) ?? positiveInteger(attributes.id);
|
|
57
|
+
const width = positiveInteger(attributes.width) ?? positiveInteger(media.width);
|
|
58
|
+
const height = positiveInteger(attributes.height) ?? positiveInteger(media.height);
|
|
59
|
+
const alt = typeof attributes.alt === "string"
|
|
60
|
+
? attributes.alt
|
|
61
|
+
: typeof media.alt === "string"
|
|
62
|
+
? media.alt
|
|
63
|
+
: "";
|
|
64
|
+
const caption = text(attributes.caption) || text(media.caption);
|
|
65
|
+
const title = text(attributes.title) || text(media.title) || undefined;
|
|
66
|
+
const srcSet = text(media.srcSet) || undefined;
|
|
67
|
+
const sizes = srcSet ? text(media.sizes) || undefined : undefined;
|
|
68
|
+
const authoredHref = text(attributes.href) || text(media.href);
|
|
69
|
+
const lightbox = attributes.lightbox && typeof attributes.lightbox === "object"
|
|
70
|
+
? attributes.lightbox as Record<string, unknown>
|
|
71
|
+
: {};
|
|
72
|
+
const lightboxEnabled = lightbox.enabled === true || media.lightboxEnabled === true;
|
|
73
|
+
const lightboxHref = lightboxEnabled && !authoredHref ? text(media.fullUrl) || src : "";
|
|
74
|
+
const href = authoredHref || lightboxHref || undefined;
|
|
75
|
+
const external = (attributes.linkTarget ?? media.linkTarget) === "_blank";
|
|
76
|
+
const authoredRel = text(attributes.rel) || text(media.rel);
|
|
77
|
+
const rel = external
|
|
78
|
+
? [...new Set([...authoredRel.split(/\s+/).filter(Boolean), "noopener", "noreferrer"])].join(" ")
|
|
79
|
+
: authoredRel || undefined;
|
|
80
|
+
const align = ["left", "center", "right", "wide", "full"].includes(String(attributes.align))
|
|
81
|
+
? `align${String(attributes.align)}`
|
|
82
|
+
: "";
|
|
83
|
+
const sizeSlug = text(attributes.sizeSlug).replace(/[^a-z0-9_-]/gi, "");
|
|
84
|
+
const sizeClass = sizeSlug ? `size-${sizeSlug}` : "";
|
|
85
|
+
const rootProps = {
|
|
86
|
+
...htmlProps,
|
|
87
|
+
class: classNames("wp-block-image", align, sizeClass, media.figureClass, htmlProps.class) ?? "",
|
|
88
|
+
};
|
|
89
|
+
const imageClass = classNames(
|
|
90
|
+
id ? `wp-image-${id}` : "",
|
|
91
|
+
media.imageClass,
|
|
92
|
+
attributes.imageClassName,
|
|
93
|
+
);
|
|
94
|
+
const imageProps = {
|
|
95
|
+
src,
|
|
96
|
+
srcset: srcSet,
|
|
97
|
+
sizes,
|
|
98
|
+
width,
|
|
99
|
+
height,
|
|
100
|
+
alt,
|
|
101
|
+
title,
|
|
102
|
+
class: imageClass,
|
|
103
|
+
presentation: imageMediaStyle(attributes),
|
|
104
|
+
loading: "lazy" as const,
|
|
105
|
+
decoding: "async" as const,
|
|
106
|
+
};
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
{src ? (
|
|
110
|
+
<StyleflowElement as="figure" {...rootProps} {...styleflowProps} data-flowpress-core-image data-flowpress-image-lightbox={lightboxHref ? "link" : undefined}>
|
|
111
|
+
{href ? (
|
|
112
|
+
<StyleflowElement as="a"
|
|
113
|
+
href={href}
|
|
114
|
+
class={text(attributes.linkClass) || text(media.linkClass) || undefined}
|
|
115
|
+
target={external ? "_blank" : undefined}
|
|
116
|
+
rel={rel}
|
|
117
|
+
>
|
|
118
|
+
<Media {...imageProps} />
|
|
119
|
+
</StyleflowElement>
|
|
120
|
+
) : <Media {...imageProps} />}
|
|
121
|
+
{caption ? (
|
|
122
|
+
<StyleflowElement as="figcaption" class="wp-element-caption">
|
|
123
|
+
<Fragment set:html={caption} />
|
|
124
|
+
</StyleflowElement>
|
|
125
|
+
) : null}
|
|
126
|
+
</StyleflowElement>
|
|
127
|
+
) : null}
|
|
128
|
+
|
|
129
|
+
<style is:global>
|
|
130
|
+
/* Keep intrinsic HTML dimensions for layout reservation; CSS controls the
|
|
131
|
+
authored display box. Inline width/height retain the editor's units. */
|
|
132
|
+
:where([data-flowpress-core-image] > img, [data-flowpress-core-image] > a > img,
|
|
133
|
+
[data-flowpress-core-image] > svg, [data-flowpress-core-image] > a > svg) {
|
|
134
|
+
vertical-align: bottom;
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } =
|
|
7
|
+
Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const href = String(block.attributes.url ?? "").trim() || "#";
|
|
9
|
+
const label = decodeFlowpressText(block.attributes.label ?? block.attributes.title ?? href);
|
|
10
|
+
const external = block.attributes.opensInNewTab === true;
|
|
11
|
+
const authoredRel = String(block.attributes.rel ?? "").trim();
|
|
12
|
+
const rel = external
|
|
13
|
+
? [
|
|
14
|
+
...new Set([
|
|
15
|
+
...authoredRel.split(/\s+/).filter(Boolean),
|
|
16
|
+
"noopener",
|
|
17
|
+
"noreferrer",
|
|
18
|
+
]),
|
|
19
|
+
].join(" ")
|
|
20
|
+
: authoredRel || undefined;
|
|
21
|
+
const rootProps = {
|
|
22
|
+
...htmlProps,
|
|
23
|
+
class: ["wp-block-navigation-item", htmlProps.class]
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.join(" "),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// aria-current only for a link to this very page on this very site. The label of that link sits
|
|
29
|
+
// on the marker, so it takes the marker's own paired foreground (see the label below).
|
|
30
|
+
const withoutTrailingSlash = (path: string) => path.replace(/\/+$/, "") || "/";
|
|
31
|
+
let current = false;
|
|
32
|
+
try {
|
|
33
|
+
const target = new URL(href, Astro.url);
|
|
34
|
+
current =
|
|
35
|
+
!external &&
|
|
36
|
+
target.hostname === Astro.url.hostname &&
|
|
37
|
+
withoutTrailingSlash(target.pathname) ===
|
|
38
|
+
withoutTrailingSlash(Astro.url.pathname);
|
|
39
|
+
} catch {
|
|
40
|
+
current = false;
|
|
41
|
+
}
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
<StyleflowElement as="li" {...rootProps} {...styleflowProps}>
|
|
45
|
+
<StyleflowElement as="a"
|
|
46
|
+
class="wp-block-navigation-item__content site-nav__link"
|
|
47
|
+
href={href}
|
|
48
|
+
title={String(block.attributes.title ?? "").trim() || undefined}
|
|
49
|
+
target={external ? "_blank" : undefined}
|
|
50
|
+
rel={rel}
|
|
51
|
+
aria-current={current ? "page" : undefined}
|
|
52
|
+
layoutRole="control"
|
|
53
|
+
density="compact"
|
|
54
|
+
{...(!current ? { interactivePriority: "tertiary" } : {})}
|
|
55
|
+
>
|
|
56
|
+
{
|
|
57
|
+
current ? (
|
|
58
|
+
<StyleflowElement as="span"
|
|
59
|
+
class="wp-block-navigation-item__label"
|
|
60
|
+
surface="default"
|
|
61
|
+
foreground="accent"
|
|
62
|
+
noBackground
|
|
63
|
+
>
|
|
64
|
+
{label}
|
|
65
|
+
</StyleflowElement>
|
|
66
|
+
) : (
|
|
67
|
+
<StyleflowElement as="span" class="wp-block-navigation-item__label">{label}</StyleflowElement>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
</StyleflowElement>
|
|
71
|
+
</StyleflowElement>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const label = decodeFlowpressText(block.attributes.label ?? block.attributes.title ?? "Submenu");
|
|
8
|
+
const rootProps = { ...htmlProps, class: ["wp-block-navigation-item has-child", htmlProps.class].filter(Boolean).join(" ") };
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<StyleflowElement as="li" {...rootProps} {...styleflowProps}>
|
|
12
|
+
<StyleflowElement as="details" data-navigation-disclosure class="site-nav__disclosure">
|
|
13
|
+
<StyleflowElement as="summary"
|
|
14
|
+
class="site-nav__link site-nav__summary"
|
|
15
|
+
layoutRole="control"
|
|
16
|
+
density="regular"
|
|
17
|
+
interactivePriority="tertiary"
|
|
18
|
+
noBackground
|
|
19
|
+
noBorder
|
|
20
|
+
>
|
|
21
|
+
<StyleflowElement as="span" class="wp-block-navigation-item__label">{label}</StyleflowElement>
|
|
22
|
+
<StyleflowElement as="span" aria-hidden="true" class="site-nav__chevron"></StyleflowElement>
|
|
23
|
+
</StyleflowElement>
|
|
24
|
+
<StyleflowElement as="ul"
|
|
25
|
+
class="wp-block-navigation__submenu-container site-nav__submenu"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
surface="default"
|
|
29
|
+
layoutRole="panel"
|
|
30
|
+
density="compact"
|
|
31
|
+
><slot /></StyleflowElement>
|
|
32
|
+
</StyleflowElement>
|
|
33
|
+
</StyleflowElement>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import "./flowpress-navigation.css";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const ref = Number(block.resolvedData?.ref ?? block.attributes.ref ?? 0);
|
|
8
|
+
const anchor = String(block.attributes.anchor ?? "").trim();
|
|
9
|
+
// A navigation can be inserted twice with the same ref (or without one).
|
|
10
|
+
const navigationId = anchor || `flowpress-navigation-${Number.isFinite(ref) ? ref : 0}-${crypto.randomUUID()}`;
|
|
11
|
+
const label = String(
|
|
12
|
+
block.resolvedData?.ariaLabel ?? block.attributes.ariaLabel ?? "Menu principale",
|
|
13
|
+
);
|
|
14
|
+
const authoredOverlay = String(block.attributes.overlayMenu ?? block.attributes.overlay ?? "mobile");
|
|
15
|
+
const overlay = ["always", "never", "mobile"].includes(authoredOverlay) ? authoredOverlay : "mobile";
|
|
16
|
+
const layout = block.attributes.layout as { orientation?: string } | undefined;
|
|
17
|
+
const vertical = layout?.orientation === "vertical";
|
|
18
|
+
const openLabel = String(block.attributes.openMenuLabel ?? "Open menu");
|
|
19
|
+
const rawBreakpoint=String(block.attributes.overlayBreakpoint??"64rem");
|
|
20
|
+
const breakpoint=/^\d+(?:\.\d+)?rem$/.test(rawBreakpoint)&&parseFloat(rawBreakpoint)>0?rawBreakpoint:"64rem";
|
|
21
|
+
const instanceId=`fp-nav-${crypto.randomUUID()}`;
|
|
22
|
+
const mobileMax = `${Math.max(0, parseFloat(breakpoint) - 0.001).toFixed(3)}rem`;
|
|
23
|
+
const preupgradeCss=`#${instanceId}:not([data-ready="true"]) .site-nav__sheet{display:none} #${instanceId}:not([data-ready="true"]) [data-navigation-toggle]{display:none} @media(min-width:${breakpoint}){#${instanceId}:not([data-ready="true"]) .site-nav__list{flex-direction:row;flex-wrap:wrap}} @media(max-width:${mobileMax}){html[data-flowpress-navigation-js="true"] #${instanceId}[data-overlay="mobile"]:not([data-ready="true"]) [data-navigation-panel]{display:none} html[data-flowpress-navigation-js="true"] #${instanceId}[data-overlay="mobile"]:not([data-ready="true"]) [data-navigation-toggle]{display:block}} html[data-flowpress-navigation-js="true"] #${instanceId}[data-overlay="always"]:not([data-ready="true"]) [data-navigation-panel]{display:none} html[data-flowpress-navigation-js="true"] #${instanceId}[data-overlay="always"]:not([data-ready="true"]) [data-navigation-toggle]{display:block}`;
|
|
24
|
+
const closeLabel = String(block.attributes.closeMenuLabel ?? "Close menu");
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<!--
|
|
28
|
+
A disclosure, not a dialog: below the breakpoint the list opens as a card
|
|
29
|
+
under the header, from the breakpoint up it is the plain inline list.
|
|
30
|
+
Behaviour (focus, Escape, scroll lock, inert, motion preference) lives in
|
|
31
|
+
the shared navigation controller; the look in navigation.css.
|
|
32
|
+
-->
|
|
33
|
+
<!-- styleflow-ignore-next-line rule=sf-raw-html reason="Certified navigation custom element owns behavior without visual values" scope="framework" -->
|
|
34
|
+
<script is:inline>document.documentElement.dataset.flowpressNavigationJs="true";</script>
|
|
35
|
+
<style is:inline set:html={preupgradeCss} />
|
|
36
|
+
<flowpress-navigation
|
|
37
|
+
id={instanceId}
|
|
38
|
+
class="site-nav"
|
|
39
|
+
data-overlay={overlay}
|
|
40
|
+
data-orientation={vertical ? "vertical" : "horizontal"}
|
|
41
|
+
data-overlay-breakpoint={breakpoint}
|
|
42
|
+
data-open-label={openLabel}
|
|
43
|
+
data-close-label={closeLabel}
|
|
44
|
+
>
|
|
45
|
+
<StyleflowElement as="nav" {...htmlProps} {...styleflowProps} layoutRole="none" aria-label={label}>
|
|
46
|
+
<StyleflowElement as="button"
|
|
47
|
+
type="button"
|
|
48
|
+
data-navigation-toggle
|
|
49
|
+
aria-expanded="false"
|
|
50
|
+
aria-controls={`${navigationId}-panel`}
|
|
51
|
+
aria-label={openLabel}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
surface="default"
|
|
55
|
+
foreground="primary"
|
|
56
|
+
layoutRole="control"
|
|
57
|
+
density="compact"
|
|
58
|
+
interactivePriority="tertiary"
|
|
59
|
+
class="site-nav__toggle sf-motion-menu-toggle"
|
|
60
|
+
>
|
|
61
|
+
<StyleflowElement as="span" class="sr-only">{openLabel}</StyleflowElement>
|
|
62
|
+
<StyleflowElement as="span" aria-hidden="true" class="sf-motion-menu-toggle__icon relative block size-5">
|
|
63
|
+
<StyleflowElement as="span" class="sf-motion-menu-toggle__line"></StyleflowElement>
|
|
64
|
+
<StyleflowElement as="span" class="sf-motion-menu-toggle__line"></StyleflowElement>
|
|
65
|
+
</StyleflowElement>
|
|
66
|
+
</StyleflowElement>
|
|
67
|
+
<StyleflowElement as="div"
|
|
68
|
+
data-navigation-backdrop
|
|
69
|
+
data-sf-motion-state="closed"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
surface="default"
|
|
73
|
+
layoutRole="none"
|
|
74
|
+
class="sf-motion-backdrop site-nav__backdrop"
|
|
75
|
+
hidden
|
|
76
|
+
></StyleflowElement>
|
|
77
|
+
<StyleflowElement as="div"
|
|
78
|
+
id={`${navigationId}-panel`}
|
|
79
|
+
data-navigation-panel
|
|
80
|
+
data-sf-motion-state="closed"
|
|
81
|
+
layoutRole="none"
|
|
82
|
+
class="site-nav__panel"
|
|
83
|
+
>
|
|
84
|
+
<StyleflowElement as="span"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
surface="default"
|
|
89
|
+
layoutRole="panel"
|
|
90
|
+
density="regular"
|
|
91
|
+
class="site-nav__sheet"
|
|
92
|
+
></StyleflowElement>
|
|
93
|
+
<StyleflowElement as="ul" layoutRole="stack" density="regular" class="site-nav__list"><slot /></StyleflowElement>
|
|
94
|
+
</StyleflowElement>
|
|
95
|
+
</StyleflowElement>
|
|
96
|
+
</flowpress-navigation>
|
|
97
|
+
|
|
98
|
+
<script>
|
|
99
|
+
import { registerFlowpressNavigation } from "./flowpress-navigation-controller.js";
|
|
100
|
+
registerFlowpressNavigation();
|
|
101
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
|
|
5
|
+
interface Props { item: Record<string, unknown>; styleflowProps?: Record<string, unknown> | undefined; htmlProps?: { id?: string | undefined; class?: string } | undefined; }
|
|
6
|
+
const { item, styleflowProps = {}, htmlProps = {} } = Astro.props;
|
|
7
|
+
const children = Array.isArray(item.children)
|
|
8
|
+
? item.children as Record<string, unknown>[]
|
|
9
|
+
: [];
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<StyleflowElement as="li" {...htmlProps} class={["wp-block-pages-list__item", htmlProps.class].filter(Boolean).join(" ")} {...styleflowProps}>
|
|
13
|
+
<StyleflowElement as="a" href={String(item.url ?? "#")}>{decodeFlowpressText(item.label)}</StyleflowElement>
|
|
14
|
+
{children.length > 0 && (
|
|
15
|
+
<StyleflowElement as="ul">
|
|
16
|
+
{children.map((child) => <Astro.self item={child} />)}
|
|
17
|
+
</StyleflowElement>
|
|
18
|
+
)}
|
|
19
|
+
</StyleflowElement>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const rootProps = { ...htmlProps, class: ["wp-block-pages-list__item", htmlProps.class].filter(Boolean).join(" ") };
|
|
7
|
+
---
|
|
8
|
+
<StyleflowElement as="li" {...rootProps} {...styleflowProps}><StyleflowElement as="a" href={String(block.attributes.url ?? "#")}>{decodeFlowpressText(block.attributes.label)}</StyleflowElement><slot /></StyleflowElement>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import PageListItem from "./core-page-list-data-item.astro";
|
|
5
|
+
|
|
6
|
+
const { block, parentBlockName, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const items = Array.isArray(block.resolvedData?.items)
|
|
8
|
+
? block.resolvedData.items as Record<string, unknown>[]
|
|
9
|
+
: [];
|
|
10
|
+
interface PageListNode extends Record<string, unknown> {
|
|
11
|
+
id?: unknown | undefined;
|
|
12
|
+
parentId?: unknown | undefined;
|
|
13
|
+
children: PageListNode[];
|
|
14
|
+
}
|
|
15
|
+
const nodes = new Map<number, PageListNode>(items.map((item) => {
|
|
16
|
+
const node = { ...item, children: [] } as PageListNode;
|
|
17
|
+
return [Number(node.id), node];
|
|
18
|
+
}));
|
|
19
|
+
const roots: PageListNode[] = [];
|
|
20
|
+
for (const item of nodes.values()) {
|
|
21
|
+
const id = Number(item.id);
|
|
22
|
+
const parent = nodes.get(Number(item.parentId));
|
|
23
|
+
if (parent && Number(parent.id) !== id) {
|
|
24
|
+
parent.children.push(item);
|
|
25
|
+
} else {
|
|
26
|
+
roots.push(item);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const nestedInNavigation = ["core/navigation", "core/navigation-submenu"]
|
|
30
|
+
.includes(parentBlockName ?? "");
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
{nestedInNavigation
|
|
34
|
+
? roots.map((item, index) => <PageListItem item={item} styleflowProps={styleflowProps} htmlProps={index === 0 ? htmlProps : undefined} />)
|
|
35
|
+
: (
|
|
36
|
+
<StyleflowElement as="ul" {...htmlProps} class={["wp-block-page-list", htmlProps.class].filter(Boolean).join(" ")} {...styleflowProps}>
|
|
37
|
+
{roots.map((item) => <PageListItem item={item} />)}
|
|
38
|
+
</StyleflowElement>
|
|
39
|
+
)}
|
|
40
|
+
<slot />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
import { classNames, text } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// Publication (or modification) date of the current loop item.
|
|
8
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
9
|
+
const datetime = text(block.resolvedData?.datetime);
|
|
10
|
+
const formatted = decodeFlowpressText(block.resolvedData?.formatted);
|
|
11
|
+
const url = text(block.resolvedData?.url);
|
|
12
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-post-date", htmlProps.class) };
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
{formatted ? (
|
|
16
|
+
<StyleflowElement as="div" {...rootProps} {...styleflowProps}>
|
|
17
|
+
{block.attributes.isLink && url
|
|
18
|
+
? <StyleflowElement as="a" href={url}><StyleflowElement as="time" datetime={datetime}>{formatted}</StyleflowElement></StyleflowElement>
|
|
19
|
+
: <StyleflowElement as="time" datetime={datetime}>{formatted}</StyleflowElement>}
|
|
20
|
+
</StyleflowElement>
|
|
21
|
+
) : null}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
import { classNames, text } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// Excerpt of the current loop item, trimmed to `excerptLength` words.
|
|
8
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
9
|
+
const attributes = block.attributes;
|
|
10
|
+
const excerpt = decodeFlowpressText(block.resolvedData?.excerpt);
|
|
11
|
+
const url = text(block.resolvedData?.url);
|
|
12
|
+
const moreText = decodeFlowpressText(attributes.moreText).trim();
|
|
13
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-post-excerpt", htmlProps.class) };
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{excerpt ? (
|
|
17
|
+
<StyleflowElement as="div" {...rootProps} {...styleflowProps}>
|
|
18
|
+
<StyleflowElement as="p" class="wp-block-post-excerpt__excerpt">
|
|
19
|
+
{excerpt}
|
|
20
|
+
{moreText && url && !attributes.showMoreOnNewLine ? <> <StyleflowElement as="a" class="wp-block-post-excerpt__more-link" href={url}>{moreText}</StyleflowElement></> : null}
|
|
21
|
+
</StyleflowElement>
|
|
22
|
+
{moreText && url && attributes.showMoreOnNewLine ? (
|
|
23
|
+
<StyleflowElement as="p" class="wp-block-post-excerpt__more-text"><StyleflowElement as="a" class="wp-block-post-excerpt__more-link" href={url}>{moreText}</StyleflowElement></StyleflowElement>
|
|
24
|
+
) : null}
|
|
25
|
+
</StyleflowElement>
|
|
26
|
+
) : null}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Media from "../EditorialMedia.astro";
|
|
3
|
+
import { imageMediaStyle } from "./image.js";
|
|
4
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
5
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
6
|
+
import { classNames, externalRel, text, type ResolvedImage } from "./query-loop.js";
|
|
7
|
+
|
|
8
|
+
// Featured image of the current loop item, with WordPress responsive sources.
|
|
9
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
10
|
+
const attributes = block.attributes;
|
|
11
|
+
const image = (block.resolvedData ?? {}) as ResolvedImage;
|
|
12
|
+
const src = text(image.url);
|
|
13
|
+
const href = attributes.isLink ? text(image.href) : "";
|
|
14
|
+
const aspectRatio = text(attributes.aspectRatio).replace(/\s+/g, "");
|
|
15
|
+
const rootProps = {
|
|
16
|
+
...htmlProps,
|
|
17
|
+
class: classNames("wp-block-post-featured-image", "project-field__image", htmlProps.class),
|
|
18
|
+
"data-aspect-ratio": aspectRatio && aspectRatio !== "auto" ? aspectRatio : undefined,
|
|
19
|
+
};
|
|
20
|
+
const imageProps = {
|
|
21
|
+
src,
|
|
22
|
+
srcset: image.srcSet || undefined,
|
|
23
|
+
sizes: image.srcSet ? image.sizes || undefined : undefined,
|
|
24
|
+
width: image.width,
|
|
25
|
+
height: image.height,
|
|
26
|
+
alt: typeof attributes.alt === "string" && attributes.alt ? attributes.alt : image.alt ?? "",
|
|
27
|
+
class: image.id ? `wp-image-${image.id}` : undefined,
|
|
28
|
+
loading: "lazy" as const,
|
|
29
|
+
decoding: "async" as const,
|
|
30
|
+
presentation: imageMediaStyle(attributes),
|
|
31
|
+
};
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
{src ? (
|
|
35
|
+
<StyleflowElement as="figure" {...rootProps} {...styleflowProps}>
|
|
36
|
+
{href
|
|
37
|
+
? <StyleflowElement as="a" href={href} target={attributes.linkTarget === "_blank" ? "_blank" : undefined} rel={externalRel(attributes.linkTarget, attributes.rel)}><Media {...imageProps} /></StyleflowElement>
|
|
38
|
+
: <Media {...imageProps} />}
|
|
39
|
+
</StyleflowElement>
|
|
40
|
+
) : null}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import ResolvedBlocks from "./ResolvedBlocks.astro";
|
|
5
|
+
import { classNames, type LoopTemplateData } from "./query-loop.js";
|
|
6
|
+
import { bleedClasses, gridClasses, isGrid, spanClasses, usedSpanClasses } from "./grid.js";
|
|
7
|
+
|
|
8
|
+
// core/post-template: one resolved copy of the template per queried post.
|
|
9
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
10
|
+
const { block, htmlProps, styleflowProps } = props;
|
|
11
|
+
const data = (block.resolvedData ?? {}) as LoopTemplateData;
|
|
12
|
+
const items = data.items ?? [];
|
|
13
|
+
const grid = isGrid(block.name, block.attributes);
|
|
14
|
+
const childAttributes = items.map((item) => item.blocks?.[0]?.attributes || {});
|
|
15
|
+
const bleed = grid ? bleedClasses(block.attributes, childAttributes) : [];
|
|
16
|
+
const rootProps = {
|
|
17
|
+
...htmlProps,
|
|
18
|
+
class: classNames("wp-block-post-template", grid ? "is-layout-grid" : "", htmlProps.class, grid ? gridClasses(block.attributes).join(" ") : ""),
|
|
19
|
+
};
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
{items.length > 0 ? (
|
|
23
|
+
<StyleflowElement as="ul" {...rootProps} {...styleflowProps}>
|
|
24
|
+
{items.map((item, index) => (
|
|
25
|
+
<StyleflowElement as="li" class={classNames("wp-block-post", `post-${item.id}`, item.postType ? `type-${item.postType}` : "", grid ? [...spanClasses((childAttributes[index] ?? {})), ...usedSpanClasses(block.attributes, (childAttributes[index] ?? {})), ...(bleed[index] ?? [])].join(" ") : "")}>
|
|
26
|
+
<ResolvedBlocks {...props} blocks={item.blocks} pass={data} renderPassOutput={index === 0} />
|
|
27
|
+
</StyleflowElement>
|
|
28
|
+
))}
|
|
29
|
+
</StyleflowElement>
|
|
30
|
+
) : null}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
import DefaultBlockAdapter from "./core-post-template-fallback.astro";
|
|
3
|
+
// Query Loop carousel with the shared static fallback.
|
|
4
|
+
import ResolvedBlocks from "./ResolvedBlocks.astro";
|
|
5
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
6
|
+
import { queryCarouselBlocks, type QueryCarouselData } from "./query-carousel.js";
|
|
7
|
+
|
|
8
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
9
|
+
const blocks = queryCarouselBlocks(props);
|
|
10
|
+
const pass = (props.block.resolvedData ?? {}) as QueryCarouselData;
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
{blocks === undefined ? (
|
|
14
|
+
<DefaultBlockAdapter {...props} />
|
|
15
|
+
) : (
|
|
16
|
+
<ResolvedBlocks {...props} blocks={blocks} pass={pass} />
|
|
17
|
+
)}
|
|
18
|
+
|
|
19
|
+
<style is:global>
|
|
20
|
+
/* Splide core hides its root until mount. Keep the shared static grid
|
|
21
|
+
readable when JavaScript is unavailable or initialization fails. */
|
|
22
|
+
.flowpress-query-carousel:not(.is-initialized) { visibility: visible; }
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
|
+
import TermFieldValue from "./TermFieldValue.astro";
|
|
6
|
+
import { classNames, text } from "./query-loop.js";
|
|
7
|
+
|
|
8
|
+
// Terms of one taxonomy assigned to the current loop item. With a term custom
|
|
9
|
+
// field picked (custom-fields.php) each term shows the field instead of, or
|
|
10
|
+
// next to, its name; a term without a value keeps its name.
|
|
11
|
+
interface TermField { as?: string | undefined; value?: unknown }
|
|
12
|
+
interface TermLink { id: number; name: string; url: string; field?: TermField }
|
|
13
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
14
|
+
const attributes = block.attributes;
|
|
15
|
+
const terms = (Array.isArray(block.resolvedData?.terms) ? block.resolvedData.terms : []) as TermLink[];
|
|
16
|
+
const display = text(block.resolvedData?.display);
|
|
17
|
+
const separator = typeof attributes.separator === "string" ? decodeFlowpressText(attributes.separator) : ", ";
|
|
18
|
+
const prefix = decodeFlowpressText(attributes.prefix);
|
|
19
|
+
const suffix = decodeFlowpressText(attributes.suffix);
|
|
20
|
+
const rootProps = {
|
|
21
|
+
...htmlProps,
|
|
22
|
+
class: classNames("wp-block-post-terms", `taxonomy-${text(attributes.term)}`, htmlProps.class),
|
|
23
|
+
};
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
{terms.length > 0 ? (
|
|
27
|
+
<StyleflowElement as="div" {...rootProps} {...styleflowProps}>
|
|
28
|
+
{prefix ? <StyleflowElement as="span" class="wp-block-post-terms__prefix">{prefix}</StyleflowElement> : null}
|
|
29
|
+
{terms.map((term, index) => {
|
|
30
|
+
const field = display === "name" ? undefined : term.field;
|
|
31
|
+
const label = field ? (
|
|
32
|
+
<>
|
|
33
|
+
{display === "both" ? <StyleflowElement as="span" class="wp-block-post-terms__name">{decodeFlowpressText(term.name)}</StyleflowElement> : null}
|
|
34
|
+
{display === "both" ? " " : null}
|
|
35
|
+
<TermFieldValue field={field} fallbackAlt={display === "field" ? term.name : ""} />
|
|
36
|
+
</>
|
|
37
|
+
) : decodeFlowpressText(term.name);
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{index > 0 ? <StyleflowElement as="span" class="wp-block-post-terms__separator">{separator}</StyleflowElement> : null}
|
|
41
|
+
{term.url ? <StyleflowElement as="a" href={term.url} rel="tag">{label}</StyleflowElement> : <StyleflowElement as="span">{label}</StyleflowElement>}
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
})}
|
|
45
|
+
{suffix ? <StyleflowElement as="span" class="wp-block-post-terms__suffix">{suffix}</StyleflowElement> : null}
|
|
46
|
+
</StyleflowElement>
|
|
47
|
+
) : null}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import LevelTag from "./LevelTag.astro";
|
|
5
|
+
import { classNames, externalRel, headingLevel, text } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// Title of the current loop item (or of the route's post outside a loop).
|
|
8
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
9
|
+
const attributes = block.attributes;
|
|
10
|
+
const title = text(block.resolvedData?.title);
|
|
11
|
+
const url = text(block.resolvedData?.url);
|
|
12
|
+
const level = headingLevel(attributes.level, 2);
|
|
13
|
+
const tag = level === 0 ? "p" : `h${level}`;
|
|
14
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-post-title", htmlProps.class) };
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
{title ? (
|
|
18
|
+
<LevelTag tag={tag} {...rootProps} {...styleflowProps}>
|
|
19
|
+
{attributes.isLink && url
|
|
20
|
+
? <StyleflowElement as="a" href={url} target={attributes.linkTarget === "_blank" ? "_blank" : undefined} rel={externalRel(attributes.linkTarget, attributes.rel)}><Fragment set:html={title} /></StyleflowElement>
|
|
21
|
+
: <Fragment set:html={title} />}
|
|
22
|
+
</LevelTag>
|
|
23
|
+
) : null}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames } from "./query-loop.js";
|
|
5
|
+
|
|
6
|
+
// Shown only when the parent Query Loop returned no posts (query-loop.php).
|
|
7
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const visible = block.resolvedData?.visible === true;
|
|
9
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-query-no-results", htmlProps.class) };
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
{visible ? <StyleflowElement as="div" {...rootProps} {...styleflowProps}><slot /></StyleflowElement> : null}
|