@luhtech/site-visuals 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +25 -0
- package/package.json +40 -0
- package/src/components/Byline.astro +52 -0
- package/src/components/DiagramFigure.astro +25 -0
- package/src/components/Hero.astro +104 -0
- package/src/lib/formatPublishedDate.ts +17 -0
- package/src/lib/readingTime.ts +18 -0
- package/src/lib/resolveAssetUrl.ts +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @luhtech/site-visuals
|
|
2
|
+
|
|
3
|
+
Canonical visual components for LuhTech venture marketing sites -- responsive hero images, numbered diagram figures, and article bylines. Composes with `@luhtech/site-template` (peer dependency); does not fork or replace any of its components.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
- **`Hero.astro`** -- a real, responsive hero image (AVIF/WebP/JPEG at 768/1280/1920 via `astro:assets`' `<Picture>`), with the same eyebrow/heading/subheading/CTA treatment every other section already uses (via `@luhtech/site-template`'s `SectionHeading`/`CtaLink`). A standalone, directly-composed component -- like `SplashHero` in site-template, it is not wired into `Section.astro`'s `sectionKind` dispatch table. A page reaches for it when its hero section has a real `heroImage`.
|
|
8
|
+
- **`DiagramFigure.astro`** -- wraps site-template's own `Diagram.astro` with an optional `number` prop, prefixing the caption with "Figure N." Deliberately not named `Figure` -- site-template's `Figure.astro` already renders a different schema entity (`section.figures[]`, a cited-stat callout), not `section.diagrams[]`.
|
|
9
|
+
- **`Byline.astro`** -- author / date / reading time / series / market-cell label for an article. Prop-driven, not schema-reading (`article.schema.json` has no author/series/publishedAt fields yet -- that's separate, not-yet-landed scope). Reading time is always computed at render from real body text via `readingTimeMinutes()`, never accepted as a stored value.
|
|
10
|
+
|
|
11
|
+
## Setup in a consuming site
|
|
12
|
+
|
|
13
|
+
`astro.config.mjs` needs the asset-bank CDN host allowlisted for `astro:assets`' remote-image support:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
image: {
|
|
18
|
+
domains: ["ectropy-production-asset-bank.sfo3.cdn.digitaloceanspaces.com"],
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Asset resolution
|
|
24
|
+
|
|
25
|
+
`resolveAssetUrl(assetId, bankType, ext)` resolves an asset-bank `assetId` straight to its public CDN URL -- no runtime API call or credential, since the bucket is public-read and CDN-fronted. Registering a *new* asset (uploading bytes + writing the `asset_bank_records` row) is a separate, credentialed step (`Ectropy-Business/scripts/ingest-asset-bank.py`), out of scope for this package, which only renders assets that already exist.
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luhtech/site-visuals",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Canonical visual package for LuhTech venture sites -- responsive hero images, numbered diagram figures, and article bylines, composing with @luhtech/site-template.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "LuhTech Holdings",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/luh-tech/site-visuals.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org",
|
|
14
|
+
"access": "public",
|
|
15
|
+
"provenance": true
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./components/*": "./src/components/*",
|
|
24
|
+
"./lib/*": "./src/lib/*"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "node --experimental-strip-types --test test/*.test.mjs"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"astro": "^7.2",
|
|
31
|
+
"tailwindcss": "^4",
|
|
32
|
+
"@luhtech/site-template": ">=0.14.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {},
|
|
35
|
+
"luhtech": {
|
|
36
|
+
"schemaPins": {
|
|
37
|
+
"content/page.schema.json": "1.5.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Author / date / reading time / series / market-cell label for an
|
|
3
|
+
// article. Deliberately prop-driven, not schema-reading: article.schema.json
|
|
4
|
+
// has no author/series/publishedAt fields today (checked live this
|
|
5
|
+
// session -- that's real Phase 4 scope, not yet landed). This component
|
|
6
|
+
// takes whatever the caller has and renders nothing for a field it lacks,
|
|
7
|
+
// rather than inventing a placeholder -- so it's ready to wire to real
|
|
8
|
+
// data the moment Phase 4 adds those fields, with no rewrite needed here.
|
|
9
|
+
//
|
|
10
|
+
// Reading time is always computed here from real bodyText, never accepted
|
|
11
|
+
// as a stored prop -- matches the dispatch's own rule (Phase 4 item 2:
|
|
12
|
+
// "reading time derived at render, never stored").
|
|
13
|
+
import { readingTimeMinutes } from "../lib/readingTime.ts";
|
|
14
|
+
import { formatPublishedDate } from "../lib/formatPublishedDate.ts";
|
|
15
|
+
|
|
16
|
+
export interface Props {
|
|
17
|
+
author?: string;
|
|
18
|
+
/** ISO 8601 date string, e.g. "2026-09-09". */
|
|
19
|
+
publishedAt?: string;
|
|
20
|
+
series?: string;
|
|
21
|
+
/** 1-indexed position within `series`. Only rendered when `series` is also present. */
|
|
22
|
+
seriesOrdinal?: number;
|
|
23
|
+
/** Human-readable label, e.g. from a market-cell id via the site's own humanizeCellId() -- resolved by the caller, not here. */
|
|
24
|
+
marketCellLabel?: string;
|
|
25
|
+
bodyText: string;
|
|
26
|
+
class?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { author, publishedAt, series, seriesOrdinal, marketCellLabel, bodyText, class: className = "" } = Astro.props;
|
|
30
|
+
|
|
31
|
+
const minutes = readingTimeMinutes(bodyText);
|
|
32
|
+
|
|
33
|
+
const formattedDate = publishedAt ? formatPublishedDate(publishedAt) : undefined;
|
|
34
|
+
|
|
35
|
+
const parts: string[] = [];
|
|
36
|
+
if (author) parts.push(author);
|
|
37
|
+
if (formattedDate) parts.push(formattedDate);
|
|
38
|
+
if (minutes > 0) parts.push(`${minutes} min read`);
|
|
39
|
+
if (series) parts.push(seriesOrdinal ? `${series} · ${seriesOrdinal}` : series);
|
|
40
|
+
if (marketCellLabel) parts.push(marketCellLabel);
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
{parts.length > 0 && (
|
|
44
|
+
<p class:list={["text-sm text-ink/60 flex flex-wrap gap-x-2 gap-y-1", className]}>
|
|
45
|
+
{parts.map((p, i) => (
|
|
46
|
+
<Fragment>
|
|
47
|
+
{i > 0 && <span aria-hidden="true">·</span>}
|
|
48
|
+
<span>{p}</span>
|
|
49
|
+
</Fragment>
|
|
50
|
+
))}
|
|
51
|
+
</p>
|
|
52
|
+
)}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Numbered/captioned wrapper around site-template's own Diagram.astro.
|
|
3
|
+
// Deliberately named DiagramFigure, not Figure -- site-template already has
|
|
4
|
+
// a Figure.astro that renders a DIFFERENT schema entity (section.figures[],
|
|
5
|
+
// a cited-stat callout with required provenance), not section.diagrams[].
|
|
6
|
+
// Reusing that name here would collide two different concepts under one
|
|
7
|
+
// import path. This wraps rather than forks Diagram.astro so the three
|
|
8
|
+
// real diagram renderers (RingComparison/VectorSum/DataLineChart) stay
|
|
9
|
+
// owned in exactly one place.
|
|
10
|
+
import Diagram from "@luhtech/site-template/components/Diagram.astro";
|
|
11
|
+
|
|
12
|
+
export interface Props {
|
|
13
|
+
diagram: { diagramId: string; diagramType: string; caption?: string; data: any };
|
|
14
|
+
/** 1-indexed figure number for this page/article; omit to render with no "Figure N." prefix. */
|
|
15
|
+
number?: number;
|
|
16
|
+
class?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { diagram, number, class: className = "my-8" } = Astro.props;
|
|
20
|
+
const captioned = number
|
|
21
|
+
? { ...diagram, caption: diagram.caption ? `Figure ${number}. ${diagram.caption}` : `Figure ${number}` }
|
|
22
|
+
: diagram;
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
<Diagram diagram={captioned} class={className} />
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
// A real, responsive photographic/illustrative hero -- AVIF/WebP/JPEG at
|
|
3
|
+
// 768/1280/1920 via Astro's own built-in astro:assets <Picture> (remote
|
|
4
|
+
// image support), not a hand-rolled srcset. site-template's own
|
|
5
|
+
// sections/Hero.astro (the generic sectionKind:"hero" renderer) is
|
|
6
|
+
// text-only and deliberately untouched by this package -- this component
|
|
7
|
+
// is a standalone, directly-composed alternative a page reaches for when
|
|
8
|
+
// its hero section has a real heroImage, the same opt-in-replacement
|
|
9
|
+
// pattern Ectropy-Business's own marketing-site already uses for
|
|
10
|
+
// SplashHero (imported and used directly in index.astro, not wired into
|
|
11
|
+
// Section.astro's sectionKind dispatch table).
|
|
12
|
+
//
|
|
13
|
+
// Consuming site's astro.config.mjs must allowlist the asset-bank CDN host
|
|
14
|
+
// for astro:assets' remote-image support:
|
|
15
|
+
// image: { domains: ["ectropy-production-asset-bank.sfo3.cdn.digitaloceanspaces.com"] }
|
|
16
|
+
// -- astro:assets refuses to process a remote image from a non-allowlisted
|
|
17
|
+
// host at build time; this is a real per-site config step, not automatic.
|
|
18
|
+
import { Picture } from "astro:assets";
|
|
19
|
+
import SectionHeading from "@luhtech/site-template/components/SectionHeading.astro";
|
|
20
|
+
import CtaLink from "@luhtech/site-template/components/CtaLink.astro";
|
|
21
|
+
import { resolveAssetUrl, type AssetExt, type BankType } from "../lib/resolveAssetUrl.ts";
|
|
22
|
+
|
|
23
|
+
export interface Cta {
|
|
24
|
+
label: string;
|
|
25
|
+
href: string;
|
|
26
|
+
intent?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Props {
|
|
30
|
+
assetId: string;
|
|
31
|
+
bankType?: BankType;
|
|
32
|
+
ext?: AssetExt;
|
|
33
|
+
alt: string;
|
|
34
|
+
eyebrow?: string;
|
|
35
|
+
/** Optional: omit for a pure-image hero band with no text overlay (SectionHeading already renders nothing when heading is absent). */
|
|
36
|
+
heading?: string;
|
|
37
|
+
subheading?: string;
|
|
38
|
+
ctas?: Cta[];
|
|
39
|
+
/** CSS object-position value, e.g. "50% 30%" -- where the subject sits when the crop tightens. */
|
|
40
|
+
focalPoint?: string;
|
|
41
|
+
overlay?: "dark" | "light" | "none";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
assetId,
|
|
46
|
+
bankType = "image",
|
|
47
|
+
ext = "png",
|
|
48
|
+
alt,
|
|
49
|
+
eyebrow,
|
|
50
|
+
heading,
|
|
51
|
+
subheading,
|
|
52
|
+
ctas = [],
|
|
53
|
+
focalPoint = "50% 50%",
|
|
54
|
+
overlay = "dark",
|
|
55
|
+
} = Astro.props;
|
|
56
|
+
|
|
57
|
+
const src = resolveAssetUrl(assetId, bankType, ext);
|
|
58
|
+
|
|
59
|
+
const OVERLAY_CLASS: Record<NonNullable<Props["overlay"]>, string> = {
|
|
60
|
+
dark: "bg-ink/55",
|
|
61
|
+
light: "bg-canvas/55",
|
|
62
|
+
none: "",
|
|
63
|
+
};
|
|
64
|
+
const TEXT_TONE_CLASS: Record<NonNullable<Props["overlay"]>, string> = {
|
|
65
|
+
dark: "text-canvas",
|
|
66
|
+
light: "text-ink",
|
|
67
|
+
none: "text-ink",
|
|
68
|
+
};
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
<section class="relative overflow-hidden" data-reveal>
|
|
72
|
+
<div class="absolute inset-0 -z-10">
|
|
73
|
+
<Picture
|
|
74
|
+
src={src}
|
|
75
|
+
inferSize
|
|
76
|
+
widths={[768, 1280, 1920]}
|
|
77
|
+
sizes="100vw"
|
|
78
|
+
formats={["avif", "webp", "jpeg"]}
|
|
79
|
+
fallbackFormat="jpeg"
|
|
80
|
+
alt={alt}
|
|
81
|
+
loading="eager"
|
|
82
|
+
fetchpriority="high"
|
|
83
|
+
class="w-full h-full object-cover"
|
|
84
|
+
style={`object-position: ${focalPoint}`}
|
|
85
|
+
/>
|
|
86
|
+
{overlay !== "none" && <div class:list={["absolute inset-0", OVERLAY_CLASS[overlay]]} aria-hidden="true" />}
|
|
87
|
+
</div>
|
|
88
|
+
<div class:list={["relative py-24 sm:py-32 px-6 max-w-4xl mx-auto", TEXT_TONE_CLASS[overlay]]}>
|
|
89
|
+
<SectionHeading
|
|
90
|
+
level="h1"
|
|
91
|
+
eyebrow={eyebrow}
|
|
92
|
+
heading={heading}
|
|
93
|
+
subheading={subheading}
|
|
94
|
+
headingClass="text-4xl sm:text-5xl leading-tight"
|
|
95
|
+
subheadingClass="text-lg"
|
|
96
|
+
class="mb-4"
|
|
97
|
+
/>
|
|
98
|
+
{ctas.length > 0 && (
|
|
99
|
+
<div class="mt-6 flex gap-4 flex-wrap">
|
|
100
|
+
{ctas.map((c, i) => <CtaLink cta={c} variant={i === 0 ? "primary" : "secondary"} />)}
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
</section>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a bare calendar date (no time-of-day meaning) for display.
|
|
3
|
+
* Always formats in UTC, never the runtime's local timezone -- a bare
|
|
4
|
+
* date string has no timezone of its own, and `new Date(dateString)`
|
|
5
|
+
* parses it as UTC midnight, so letting toLocaleDateString format in the
|
|
6
|
+
* local timezone silently shifts the displayed day backward for any
|
|
7
|
+
* timezone behind UTC. Found live this session: "2026-09-14" rendered as
|
|
8
|
+
* "September 13, 2026" on a build machine in UTC-7.
|
|
9
|
+
*/
|
|
10
|
+
export function formatPublishedDate(isoDate: string): string {
|
|
11
|
+
return new Date(isoDate).toLocaleDateString("en-US", {
|
|
12
|
+
year: "numeric",
|
|
13
|
+
month: "long",
|
|
14
|
+
day: "numeric",
|
|
15
|
+
timeZone: "UTC",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading time is derived at render from real body text, never stored on
|
|
3
|
+
* the content instance -- matches the GTM launch-surface dispatch's own
|
|
4
|
+
* rule for Byline (Phase 4, item 2: "reading time derived at render, never
|
|
5
|
+
* stored"). 200 words/minute is the commonly-cited average adult silent
|
|
6
|
+
* reading speed for prose (the figure most reading-time estimators, e.g.
|
|
7
|
+
* Medium's, converge on) -- not independently benchmarked here, named so a
|
|
8
|
+
* future revision has a real number to argue with instead of a bare magic
|
|
9
|
+
* constant.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const WORDS_PER_MINUTE = 200;
|
|
13
|
+
|
|
14
|
+
export function readingTimeMinutes(bodyText: string): number {
|
|
15
|
+
const words = bodyText.trim().split(/\s+/).filter(Boolean).length;
|
|
16
|
+
if (words === 0) return 0;
|
|
17
|
+
return Math.max(1, Math.round(words / WORDS_PER_MINUTE));
|
|
18
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves an asset-bank assetId to its real, public CDN URL. Deliberately
|
|
3
|
+
* has no runtime dependency on the asset-bank registration API or any
|
|
4
|
+
* credential: the bucket (ectropy-production-asset-bank) is public-read and
|
|
5
|
+
* CDN-fronted, and every real asset already in it follows this exact key
|
|
6
|
+
* convention -- confirmed live this session against 15 real objects and the
|
|
7
|
+
* identical hardcoded pattern already used in
|
|
8
|
+
* Ectropy-Business/apps/marketing-site/src/layouts/Layout.astro and
|
|
9
|
+
* src/pages/index.astro. This function makes that convention a single named
|
|
10
|
+
* place instead of a repeated string literal.
|
|
11
|
+
*
|
|
12
|
+
* The bucket name is portfolio-wide despite its "ectropy-production-*" name
|
|
13
|
+
* -- it holds hero images for every venture (hilja, jobsitecontrol, ohjaus,
|
|
14
|
+
* qullqa, raizal, replique, siltana, viiva, ectropy), co-located here per L4
|
|
15
|
+
* direction rather than a dedicated per-venture bucket.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const ASSET_BANK_CDN_HOST = "ectropy-production-asset-bank.sfo3.cdn.digitaloceanspaces.com";
|
|
19
|
+
|
|
20
|
+
const ASSET_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
21
|
+
|
|
22
|
+
export type BankType = "logo" | "image" | "icon" | "diagram";
|
|
23
|
+
|
|
24
|
+
const BANK_TYPE_DIR: Record<BankType, string> = {
|
|
25
|
+
logo: "logo",
|
|
26
|
+
image: "image",
|
|
27
|
+
icon: "icon",
|
|
28
|
+
diagram: "diagram",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Matches asset-bank.schema.json's real mimeType enum
|
|
33
|
+
* (image/svg+xml, image/png, image/jpeg, image/webp, image/avif) and its
|
|
34
|
+
* MIME_TO_EXT mapping in Ectropy-Business/scripts/ingest-asset-bank.py.
|
|
35
|
+
*/
|
|
36
|
+
export type AssetExt = "svg" | "png" | "jpg" | "webp" | "avif";
|
|
37
|
+
|
|
38
|
+
export function resolveAssetUrl(assetId: string, bankType: BankType, ext: AssetExt): string {
|
|
39
|
+
if (!ASSET_ID_PATTERN.test(assetId)) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`resolveAssetUrl: assetId ${JSON.stringify(assetId)} does not match asset-bank.schema.json's real assetId pattern ${ASSET_ID_PATTERN.source}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const dir = BANK_TYPE_DIR[bankType];
|
|
45
|
+
return `https://${ASSET_BANK_CDN_HOST}/${dir}/${assetId}.${ext}`;
|
|
46
|
+
}
|