@styleflow.app/flowpress-astro-core 1.0.0-beta.2 → 1.0.0-beta.21
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 +151 -1
- package/README.md +111 -3
- package/dist/astro/BaseLayout.astro +10 -6
- package/dist/astro/CompositionRenderer.astro +157 -0
- package/dist/astro/DefaultBlockAdapter.astro +35 -0
- package/dist/astro/DefaultTemplate.astro +6 -1
- package/dist/astro/GutenbergRenderer.astro +231 -72
- package/dist/astro/ThemeRuntime.astro +24 -0
- package/dist/astro/blocks/CarouselBlock.astro +7 -9
- package/dist/astro/blocks/CarouselItemBlock.astro +3 -3
- package/dist/astro/blocks/ColumnBlock.astro +3 -4
- package/dist/astro/blocks/CoverBlock.astro +155 -0
- package/dist/astro/blocks/FormBlock.astro +18 -16
- package/dist/astro/blocks/GridBlock.astro +3 -3
- package/dist/astro/blocks/HeroBlock.astro +3 -4
- package/dist/astro/blocks/ImageBlock.astro +3 -4
- package/dist/astro/blocks/ListItemFallback.astro +7 -5
- package/dist/astro/blocks/NumberSpinnerBlock.astro +25 -19
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
- package/dist/astro/blocks/TextBlock.astro +29 -25
- package/dist/astro/blocks/ThemeToggleBlock.astro +23 -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 +7 -0
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +51 -41
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +63 -45
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +86 -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 +33 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ResolvedBlocks.astro +89 -0
- package/dist/astro/native/SyncedPatternContent.astro +92 -0
- package/dist/astro/native/TermFieldValue.astro +37 -0
- package/dist/astro/native/Timeline.astro +20 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -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/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/core-block.astro +18 -0
- package/dist/astro/native/core-button.astro +43 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +23 -0
- package/dist/astro/native/core-home-link.astro +11 -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 +124 -0
- package/dist/astro/native/core-navigation-link.astro +70 -0
- package/dist/astro/native/core-navigation-submenu.astro +32 -0
- package/dist/astro/native/core-navigation.astro +94 -0
- package/dist/astro/native/core-page-list-data-item.astro +18 -0
- package/dist/astro/native/core-page-list-item.astro +7 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +20 -0
- package/dist/astro/native/core-post-excerpt.astro +25 -0
- package/dist/astro/native/core-post-featured-image.astro +37 -0
- package/dist/astro/native/core-post-template.astro +30 -0
- package/dist/astro/native/core-post-terms.astro +46 -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-site-title.astro +15 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +20 -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/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 +17 -0
- package/dist/astro/native/grid-bleed.js +106 -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 +103 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +118 -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/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-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 +72 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +72 -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-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/block-renderers.d.ts +20 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/client.d.ts +17 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +63 -9
- 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 +124 -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 +107 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/links.d.ts +5 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +32 -0
- package/dist/links.js.map +1 -0
- package/dist/media.d.ts +28 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +212 -0
- package/dist/media.js.map +1 -0
- package/dist/styleflow.d.ts +16 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +67 -7
- package/dist/styleflow.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +77 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +84 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +13 -4
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
|
|
5
|
+
type ImageResolvedData = {
|
|
6
|
+
id?: number | undefined;
|
|
7
|
+
url?: string | undefined;
|
|
8
|
+
fullUrl?: string | undefined;
|
|
9
|
+
alt?: string | undefined;
|
|
10
|
+
width?: number | undefined;
|
|
11
|
+
height?: number | undefined;
|
|
12
|
+
srcSet?: string | undefined;
|
|
13
|
+
sizes?: string | undefined;
|
|
14
|
+
caption?: string | undefined;
|
|
15
|
+
figureClass?: string | undefined;
|
|
16
|
+
href?: string | undefined;
|
|
17
|
+
imageClass?: string | undefined;
|
|
18
|
+
linkClass?: string | undefined;
|
|
19
|
+
linkTarget?: string | undefined;
|
|
20
|
+
lightboxEnabled?: boolean | undefined;
|
|
21
|
+
rel?: string | undefined;
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const { block, htmlProps, styleflowProps: rendererStyleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
26
|
+
const attributes = block.attributes;
|
|
27
|
+
const media = (block.resolvedData ?? {}) as ImageResolvedData;
|
|
28
|
+
// A native image is not a stack container. The semantic renderer supplies
|
|
29
|
+
// stack/regular defaults inside sf/* layouts, which override authored image
|
|
30
|
+
// utilities such as rounded-lg. Only apply layout coordinates it authors.
|
|
31
|
+
const { layoutRole: inheritedRole, density: inheritedDensity, ...remainingSemantic } = rendererStyleflowProps;
|
|
32
|
+
const styleflowProps = attributes.layoutRole ? rendererStyleflowProps : remainingSemantic;
|
|
33
|
+
|
|
34
|
+
function text(value: unknown): string {
|
|
35
|
+
return typeof value === "string" ? value.trim() : "";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function positiveInteger(value: unknown): number | undefined {
|
|
39
|
+
const match = String(value ?? "").trim().match(/^(\d+)(?:px)?$/);
|
|
40
|
+
const number = match ? Number(match[1]) : Number(value);
|
|
41
|
+
return Number.isInteger(number) && number > 0 ? number : undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function classNames(...values: unknown[]): string | undefined {
|
|
45
|
+
const className = [...new Set(
|
|
46
|
+
values
|
|
47
|
+
.flatMap((value) => String(value ?? "").split(/\s+/))
|
|
48
|
+
.filter(Boolean),
|
|
49
|
+
)].join(" ");
|
|
50
|
+
return className || undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const src = text(media.url) || text(attributes.url);
|
|
54
|
+
const id = positiveInteger(media.id) ?? positiveInteger(attributes.id);
|
|
55
|
+
const width = positiveInteger(attributes.width) ?? positiveInteger(media.width);
|
|
56
|
+
const height = positiveInteger(attributes.height) ?? positiveInteger(media.height);
|
|
57
|
+
const alt = typeof attributes.alt === "string"
|
|
58
|
+
? attributes.alt
|
|
59
|
+
: typeof media.alt === "string"
|
|
60
|
+
? media.alt
|
|
61
|
+
: "";
|
|
62
|
+
const caption = text(attributes.caption) || text(media.caption);
|
|
63
|
+
const title = text(attributes.title) || text(media.title) || undefined;
|
|
64
|
+
const srcSet = text(media.srcSet) || undefined;
|
|
65
|
+
const sizes = srcSet ? text(media.sizes) || undefined : undefined;
|
|
66
|
+
const authoredHref = text(attributes.href) || text(media.href);
|
|
67
|
+
const lightbox = attributes.lightbox && typeof attributes.lightbox === "object"
|
|
68
|
+
? attributes.lightbox as Record<string, unknown>
|
|
69
|
+
: {};
|
|
70
|
+
const lightboxEnabled = lightbox.enabled === true || media.lightboxEnabled === true;
|
|
71
|
+
const lightboxHref = lightboxEnabled && !authoredHref ? text(media.fullUrl) || src : "";
|
|
72
|
+
const href = authoredHref || lightboxHref || undefined;
|
|
73
|
+
const external = (attributes.linkTarget ?? media.linkTarget) === "_blank";
|
|
74
|
+
const authoredRel = text(attributes.rel) || text(media.rel);
|
|
75
|
+
const rel = external
|
|
76
|
+
? [...new Set([...authoredRel.split(/\s+/).filter(Boolean), "noopener", "noreferrer"])].join(" ")
|
|
77
|
+
: authoredRel || undefined;
|
|
78
|
+
const align = ["left", "center", "right", "wide", "full"].includes(String(attributes.align))
|
|
79
|
+
? `align${String(attributes.align)}`
|
|
80
|
+
: "";
|
|
81
|
+
const sizeSlug = text(attributes.sizeSlug).replace(/[^a-z0-9_-]/gi, "");
|
|
82
|
+
const sizeClass = sizeSlug ? `size-${sizeSlug}` : "";
|
|
83
|
+
const rootProps = {
|
|
84
|
+
...htmlProps,
|
|
85
|
+
class: classNames("wp-block-image", align, sizeClass, media.figureClass, htmlProps.class) ?? "",
|
|
86
|
+
};
|
|
87
|
+
const imageClass = classNames(
|
|
88
|
+
id ? `wp-image-${id}` : "",
|
|
89
|
+
media.imageClass,
|
|
90
|
+
attributes.imageClassName,
|
|
91
|
+
);
|
|
92
|
+
const imageProps = {
|
|
93
|
+
src,
|
|
94
|
+
srcset: srcSet,
|
|
95
|
+
sizes,
|
|
96
|
+
width,
|
|
97
|
+
height,
|
|
98
|
+
alt,
|
|
99
|
+
title,
|
|
100
|
+
class: imageClass,
|
|
101
|
+
loading: "lazy" as const,
|
|
102
|
+
decoding: "async" as const,
|
|
103
|
+
};
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
{src ? (
|
|
107
|
+
<S.figure {...rootProps} {...styleflowProps} data-flowpress-image-lightbox={lightboxHref ? "link" : undefined}>
|
|
108
|
+
{href ? (
|
|
109
|
+
<S.a
|
|
110
|
+
href={href}
|
|
111
|
+
class={text(attributes.linkClass) || text(media.linkClass) || undefined}
|
|
112
|
+
target={external ? "_blank" : undefined}
|
|
113
|
+
rel={rel}
|
|
114
|
+
>
|
|
115
|
+
<S.img {...imageProps} />
|
|
116
|
+
</S.a>
|
|
117
|
+
) : <S.img {...imageProps} />}
|
|
118
|
+
{caption ? (
|
|
119
|
+
<S.figcaption class="wp-element-caption">
|
|
120
|
+
<Fragment set:html={caption} />
|
|
121
|
+
</S.figcaption>
|
|
122
|
+
) : null}
|
|
123
|
+
</S.figure>
|
|
124
|
+
) : null}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
|
|
5
|
+
const { block, htmlProps, styleflowProps } =
|
|
6
|
+
Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const href = String(block.attributes.url ?? "").trim() || "#";
|
|
8
|
+
const label = String(block.attributes.label ?? block.attributes.title ?? href);
|
|
9
|
+
const external = block.attributes.opensInNewTab === true;
|
|
10
|
+
const authoredRel = String(block.attributes.rel ?? "").trim();
|
|
11
|
+
const rel = external
|
|
12
|
+
? [
|
|
13
|
+
...new Set([
|
|
14
|
+
...authoredRel.split(/\s+/).filter(Boolean),
|
|
15
|
+
"noopener",
|
|
16
|
+
"noreferrer",
|
|
17
|
+
]),
|
|
18
|
+
].join(" ")
|
|
19
|
+
: authoredRel || undefined;
|
|
20
|
+
const rootProps = {
|
|
21
|
+
...htmlProps,
|
|
22
|
+
class: ["wp-block-navigation-item", htmlProps.class]
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.join(" "),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// aria-current only for a link to this very page on this very site. The label of that link sits
|
|
28
|
+
// on the marker, so it takes the marker's own paired foreground (see the label below).
|
|
29
|
+
const withoutTrailingSlash = (path: string) => path.replace(/\/+$/, "") || "/";
|
|
30
|
+
let current = false;
|
|
31
|
+
try {
|
|
32
|
+
const target = new URL(href, Astro.url);
|
|
33
|
+
current =
|
|
34
|
+
!external &&
|
|
35
|
+
target.hostname === Astro.url.hostname &&
|
|
36
|
+
withoutTrailingSlash(target.pathname) ===
|
|
37
|
+
withoutTrailingSlash(Astro.url.pathname);
|
|
38
|
+
} catch {
|
|
39
|
+
current = false;
|
|
40
|
+
}
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
<S.li {...rootProps} {...styleflowProps}>
|
|
44
|
+
<S.a
|
|
45
|
+
class="wp-block-navigation-item__content site-nav__link"
|
|
46
|
+
href={href}
|
|
47
|
+
title={String(block.attributes.title ?? "").trim() || undefined}
|
|
48
|
+
target={external ? "_blank" : undefined}
|
|
49
|
+
rel={rel}
|
|
50
|
+
aria-current={current ? "page" : undefined}
|
|
51
|
+
layoutRole="control"
|
|
52
|
+
density="compact"
|
|
53
|
+
{...(!current ? { interactivePriority: "tertiary" } : {})}
|
|
54
|
+
>
|
|
55
|
+
{
|
|
56
|
+
current ? (
|
|
57
|
+
<S.span
|
|
58
|
+
class="wp-block-navigation-item__label"
|
|
59
|
+
surface="default"
|
|
60
|
+
foreground="accent"
|
|
61
|
+
noBackground
|
|
62
|
+
>
|
|
63
|
+
{label}
|
|
64
|
+
</S.span>
|
|
65
|
+
) : (
|
|
66
|
+
<S.span class="wp-block-navigation-item__label">{label}</S.span>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
</S.a>
|
|
70
|
+
</S.li>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
|
|
5
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const label = String(block.attributes.label ?? block.attributes.title ?? "Submenu");
|
|
7
|
+
const rootProps = { ...htmlProps, class: ["wp-block-navigation-item has-child", htmlProps.class].filter(Boolean).join(" ") };
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<S.li {...rootProps} {...styleflowProps}>
|
|
11
|
+
<S.details data-navigation-disclosure class="site-nav__disclosure">
|
|
12
|
+
<S.summary
|
|
13
|
+
class="site-nav__link site-nav__summary"
|
|
14
|
+
layoutRole="control"
|
|
15
|
+
density="regular"
|
|
16
|
+
interactivePriority="tertiary"
|
|
17
|
+
noBackground
|
|
18
|
+
noBorder
|
|
19
|
+
>
|
|
20
|
+
<S.span class="wp-block-navigation-item__label">{label}</S.span>
|
|
21
|
+
<S.span aria-hidden="true" class="site-nav__chevron"></S.span>
|
|
22
|
+
</S.summary>
|
|
23
|
+
<S.ul
|
|
24
|
+
class="wp-block-navigation__submenu-container site-nav__submenu"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
surface="default"
|
|
28
|
+
layoutRole="panel"
|
|
29
|
+
density="compact"
|
|
30
|
+
><slot /></S.ul>
|
|
31
|
+
</S.details>
|
|
32
|
+
</S.li>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.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 closeLabel = String(block.attributes.closeMenuLabel ?? "Close menu");
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
A disclosure, not a dialog: below the breakpoint the list opens as a card
|
|
24
|
+
under the header, from the breakpoint up it is the plain inline list.
|
|
25
|
+
Behaviour (focus, Escape, scroll lock, inert, motion preference) lives in
|
|
26
|
+
the shared navigation controller; the look in navigation.css.
|
|
27
|
+
-->
|
|
28
|
+
<!-- styleflow-ignore-next-line rule=sf-raw-html reason="Certified navigation custom element owns behavior without visual values" scope="framework" -->
|
|
29
|
+
<flowpress-navigation
|
|
30
|
+
class="site-nav"
|
|
31
|
+
data-overlay={overlay}
|
|
32
|
+
data-orientation={vertical ? "vertical" : "horizontal"}
|
|
33
|
+
data-overlay-breakpoint={String(block.attributes.overlayBreakpoint ?? "64rem")}
|
|
34
|
+
data-open-label={openLabel}
|
|
35
|
+
data-close-label={closeLabel}
|
|
36
|
+
>
|
|
37
|
+
<S.nav {...htmlProps} {...styleflowProps} layoutRole="none" aria-label={label}>
|
|
38
|
+
<S.button
|
|
39
|
+
type="button"
|
|
40
|
+
data-navigation-toggle
|
|
41
|
+
aria-expanded="false"
|
|
42
|
+
aria-controls={`${navigationId}-panel`}
|
|
43
|
+
aria-label={openLabel}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
surface="default"
|
|
47
|
+
foreground="primary"
|
|
48
|
+
layoutRole="control"
|
|
49
|
+
density="compact"
|
|
50
|
+
interactivePriority="tertiary"
|
|
51
|
+
class="site-nav__toggle sf-motion-menu-toggle"
|
|
52
|
+
hidden
|
|
53
|
+
>
|
|
54
|
+
<S.span class="sr-only">{openLabel}</S.span>
|
|
55
|
+
<S.span aria-hidden="true" class="sf-motion-menu-toggle__icon relative block size-5">
|
|
56
|
+
<S.span class="sf-motion-menu-toggle__line"></S.span>
|
|
57
|
+
<S.span class="sf-motion-menu-toggle__line"></S.span>
|
|
58
|
+
</S.span>
|
|
59
|
+
</S.button>
|
|
60
|
+
<S.div
|
|
61
|
+
data-navigation-backdrop
|
|
62
|
+
data-sf-motion-state="closed"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
surface="default"
|
|
66
|
+
layoutRole="none"
|
|
67
|
+
class="sf-motion-backdrop site-nav__backdrop"
|
|
68
|
+
hidden
|
|
69
|
+
></S.div>
|
|
70
|
+
<S.div
|
|
71
|
+
id={`${navigationId}-panel`}
|
|
72
|
+
data-navigation-panel
|
|
73
|
+
data-sf-motion-state="closed"
|
|
74
|
+
layoutRole="none"
|
|
75
|
+
class="site-nav__panel"
|
|
76
|
+
>
|
|
77
|
+
<S.span
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
surface="default"
|
|
82
|
+
layoutRole="panel"
|
|
83
|
+
density="regular"
|
|
84
|
+
class="site-nav__sheet"
|
|
85
|
+
></S.span>
|
|
86
|
+
<S.ul layoutRole="stack" density="regular" class="site-nav__list"><slot /></S.ul>
|
|
87
|
+
</S.div>
|
|
88
|
+
</S.nav>
|
|
89
|
+
</flowpress-navigation>
|
|
90
|
+
|
|
91
|
+
<script>
|
|
92
|
+
import { registerFlowpressNavigation } from "./flowpress-navigation-controller.js";
|
|
93
|
+
registerFlowpressNavigation();
|
|
94
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
|
|
4
|
+
interface Props { item: Record<string, unknown>; styleflowProps?: Record<string, unknown> | undefined; htmlProps?: { id?: string | undefined; class?: string } | undefined; }
|
|
5
|
+
const { item, styleflowProps = {}, htmlProps = {} } = Astro.props;
|
|
6
|
+
const children = Array.isArray(item.children)
|
|
7
|
+
? item.children as Record<string, unknown>[]
|
|
8
|
+
: [];
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<S.li {...htmlProps} class={["wp-block-pages-list__item", htmlProps.class].filter(Boolean).join(" ")} {...styleflowProps}>
|
|
12
|
+
<S.a href={String(item.url ?? "#")}>{String(item.label ?? "")}</S.a>
|
|
13
|
+
{children.length > 0 && (
|
|
14
|
+
<S.ul>
|
|
15
|
+
{children.map((child) => <Astro.self item={child} />)}
|
|
16
|
+
</S.ul>
|
|
17
|
+
)}
|
|
18
|
+
</S.li>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
5
|
+
const rootProps = { ...htmlProps, class: ["wp-block-pages-list__item", htmlProps.class].filter(Boolean).join(" ") };
|
|
6
|
+
---
|
|
7
|
+
<S.li {...rootProps} {...styleflowProps}><S.a href={String(block.attributes.url ?? "#")}>{String(block.attributes.label ?? "")}</S.a><slot /></S.li>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.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
|
+
<S.ul {...htmlProps} class={["wp-block-page-list", htmlProps.class].filter(Boolean).join(" ")} {...styleflowProps}>
|
|
37
|
+
{roots.map((item) => <PageListItem item={item} />)}
|
|
38
|
+
</S.ul>
|
|
39
|
+
)}
|
|
40
|
+
<slot />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames, text } from "./query-loop.js";
|
|
5
|
+
|
|
6
|
+
// Publication (or modification) date of the current loop item.
|
|
7
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const datetime = text(block.resolvedData?.datetime);
|
|
9
|
+
const formatted = text(block.resolvedData?.formatted);
|
|
10
|
+
const url = text(block.resolvedData?.url);
|
|
11
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-post-date", htmlProps.class) };
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
{formatted ? (
|
|
15
|
+
<S.div {...rootProps} {...styleflowProps}>
|
|
16
|
+
{block.attributes.isLink && url
|
|
17
|
+
? <S.a href={url}><S.time datetime={datetime}>{formatted}</S.time></S.a>
|
|
18
|
+
: <S.time datetime={datetime}>{formatted}</S.time>}
|
|
19
|
+
</S.div>
|
|
20
|
+
) : null}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames, text } from "./query-loop.js";
|
|
5
|
+
|
|
6
|
+
// Excerpt of the current loop item, trimmed to `excerptLength` words.
|
|
7
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const attributes = block.attributes;
|
|
9
|
+
const excerpt = text(block.resolvedData?.excerpt);
|
|
10
|
+
const url = text(block.resolvedData?.url);
|
|
11
|
+
const moreText = text(attributes.moreText).trim();
|
|
12
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-post-excerpt", htmlProps.class) };
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
{excerpt ? (
|
|
16
|
+
<S.div {...rootProps} {...styleflowProps}>
|
|
17
|
+
<S.p class="wp-block-post-excerpt__excerpt">
|
|
18
|
+
{excerpt}
|
|
19
|
+
{moreText && url && !attributes.showMoreOnNewLine ? <> <S.a class="wp-block-post-excerpt__more-link" href={url}>{moreText}</S.a></> : null}
|
|
20
|
+
</S.p>
|
|
21
|
+
{moreText && url && attributes.showMoreOnNewLine ? (
|
|
22
|
+
<S.p class="wp-block-post-excerpt__more-text"><S.a class="wp-block-post-excerpt__more-link" href={url}>{moreText}</S.a></S.p>
|
|
23
|
+
) : null}
|
|
24
|
+
</S.div>
|
|
25
|
+
) : null}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames, externalRel, text, type ResolvedImage } from "./query-loop.js";
|
|
5
|
+
|
|
6
|
+
// Featured image of the current loop item, with WordPress responsive sources.
|
|
7
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const attributes = block.attributes;
|
|
9
|
+
const image = (block.resolvedData ?? {}) as ResolvedImage;
|
|
10
|
+
const src = text(image.url);
|
|
11
|
+
const href = attributes.isLink ? text(image.href) : "";
|
|
12
|
+
const aspectRatio = text(attributes.aspectRatio).replace(/\s+/g, "");
|
|
13
|
+
const rootProps = {
|
|
14
|
+
...htmlProps,
|
|
15
|
+
class: classNames("wp-block-post-featured-image", "project-field__image", htmlProps.class),
|
|
16
|
+
"data-aspect-ratio": aspectRatio && aspectRatio !== "auto" ? aspectRatio : undefined,
|
|
17
|
+
};
|
|
18
|
+
const imageProps = {
|
|
19
|
+
src,
|
|
20
|
+
srcset: image.srcSet || undefined,
|
|
21
|
+
sizes: image.srcSet ? image.sizes || undefined : undefined,
|
|
22
|
+
width: image.width,
|
|
23
|
+
height: image.height,
|
|
24
|
+
alt: typeof attributes.alt === "string" && attributes.alt ? attributes.alt : image.alt ?? "",
|
|
25
|
+
class: image.id ? `wp-image-${image.id}` : undefined,
|
|
26
|
+
loading: "lazy" as const,
|
|
27
|
+
decoding: "async" as const,
|
|
28
|
+
};
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
{src ? (
|
|
32
|
+
<S.figure {...rootProps} {...styleflowProps}>
|
|
33
|
+
{href
|
|
34
|
+
? <S.a href={href} target={attributes.linkTarget === "_blank" ? "_blank" : undefined} rel={externalRel(attributes.linkTarget, attributes.rel)}><S.img {...imageProps} /></S.a>
|
|
35
|
+
: <S.img {...imageProps} />}
|
|
36
|
+
</S.figure>
|
|
37
|
+
) : null}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.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
|
+
<S.ul {...rootProps} {...styleflowProps}>
|
|
24
|
+
{items.map((item, index) => (
|
|
25
|
+
<S.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
|
+
</S.li>
|
|
28
|
+
))}
|
|
29
|
+
</S.ul>
|
|
30
|
+
) : null}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import TermFieldValue from "./TermFieldValue.astro";
|
|
5
|
+
import { classNames, text } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// Terms of one taxonomy assigned to the current loop item. With a term custom
|
|
8
|
+
// field picked (custom-fields.php) each term shows the field instead of, or
|
|
9
|
+
// next to, its name; a term without a value keeps its name.
|
|
10
|
+
interface TermField { as?: string | undefined; value?: unknown }
|
|
11
|
+
interface TermLink { id: number; name: string; url: string; field?: TermField }
|
|
12
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
13
|
+
const attributes = block.attributes;
|
|
14
|
+
const terms = (Array.isArray(block.resolvedData?.terms) ? block.resolvedData.terms : []) as TermLink[];
|
|
15
|
+
const display = text(block.resolvedData?.display);
|
|
16
|
+
const separator = typeof attributes.separator === "string" ? attributes.separator : ", ";
|
|
17
|
+
const prefix = text(attributes.prefix);
|
|
18
|
+
const suffix = text(attributes.suffix);
|
|
19
|
+
const rootProps = {
|
|
20
|
+
...htmlProps,
|
|
21
|
+
class: classNames("wp-block-post-terms", `taxonomy-${text(attributes.term)}`, htmlProps.class),
|
|
22
|
+
};
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
{terms.length > 0 ? (
|
|
26
|
+
<S.div {...rootProps} {...styleflowProps}>
|
|
27
|
+
{prefix ? <S.span class="wp-block-post-terms__prefix">{prefix}</S.span> : null}
|
|
28
|
+
{terms.map((term, index) => {
|
|
29
|
+
const field = display === "name" ? undefined : term.field;
|
|
30
|
+
const label = field ? (
|
|
31
|
+
<>
|
|
32
|
+
{display === "both" ? <S.span class="wp-block-post-terms__name">{term.name}</S.span> : null}
|
|
33
|
+
{display === "both" ? " " : null}
|
|
34
|
+
<TermFieldValue field={field} fallbackAlt={display === "field" ? term.name : ""} />
|
|
35
|
+
</>
|
|
36
|
+
) : term.name;
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{index > 0 ? <S.span class="wp-block-post-terms__separator">{separator}</S.span> : null}
|
|
40
|
+
{term.url ? <S.a href={term.url} rel="tag">{label}</S.a> : <S.span>{label}</S.span>}
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
})}
|
|
44
|
+
{suffix ? <S.span class="wp-block-post-terms__suffix">{suffix}</S.span> : null}
|
|
45
|
+
</S.div>
|
|
46
|
+
) : null}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.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
|
+
? <S.a href={url} target={attributes.linkTarget === "_blank" ? "_blank" : undefined} rel={externalRel(attributes.linkTarget, attributes.rel)}><Fragment set:html={title} /></S.a>
|
|
21
|
+
: <Fragment set:html={title} />}
|
|
22
|
+
</LevelTag>
|
|
23
|
+
) : null}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.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 ? <S.div {...rootProps} {...styleflowProps}><slot /></S.div> : null}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import ResolvedBlocks from "./ResolvedBlocks.astro";
|
|
5
|
+
import { classNames, type LoopData } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// core/query: the project resolver runs the query and resolves the loop's
|
|
8
|
+
// inner blocks again with the results in context (query-loop.php). Render that
|
|
9
|
+
// nested pass, not `innerBlocks`, which were resolved with the page context.
|
|
10
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
11
|
+
const { block, htmlProps, styleflowProps } = props;
|
|
12
|
+
const data = (block.resolvedData ?? {}) as LoopData;
|
|
13
|
+
const authored = String(block.attributes.tagName ?? "div");
|
|
14
|
+
const tag = ["div", "section", "main", "aside", "article"].includes(authored) ? authored : "div";
|
|
15
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-query", htmlProps.class) };
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
{tag === "section" ? <S.section {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></S.section>
|
|
19
|
+
: tag === "main" ? <S.main {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></S.main>
|
|
20
|
+
: tag === "aside" ? <S.aside {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></S.aside>
|
|
21
|
+
: tag === "article" ? <S.article {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></S.article>
|
|
22
|
+
: <S.div {...rootProps} {...styleflowProps}><ResolvedBlocks {...props} blocks={data.blocks ?? []} pass={data} /></S.div>}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
5
|
+
const level = Number(block.attributes.level ?? 1);
|
|
6
|
+
const title = String(block.resolvedData?.title ?? "");
|
|
7
|
+
const url = String(block.resolvedData?.url ?? "/");
|
|
8
|
+
---
|
|
9
|
+
{level === 1 ? <S.h1 {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.h1>
|
|
10
|
+
: level === 2 ? <S.h2 {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.h2>
|
|
11
|
+
: level === 3 ? <S.h3 {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.h3>
|
|
12
|
+
: level === 4 ? <S.h4 {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.h4>
|
|
13
|
+
: level === 5 ? <S.h5 {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.h5>
|
|
14
|
+
: level === 6 ? <S.h6 {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.h6>
|
|
15
|
+
: <S.p {...htmlProps} {...styleflowProps}><S.a href={url}>{title}</S.a></S.p>}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { classNames, text } from "./query-loop.js";
|
|
5
|
+
|
|
6
|
+
// Description of the current Terms Query item (sanitized by WordPress).
|
|
7
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
8
|
+
const description = text(block.resolvedData?.description);
|
|
9
|
+
const rootProps = { ...htmlProps, class: classNames("wp-block-term-description", htmlProps.class) };
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
{description ? <S.div {...rootProps} {...styleflowProps}><Fragment set:html={description} /></S.div> : null}
|