sproutsite 0.5.23 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -8
- package/THIRD_PARTY_NOTICES.md +5 -3
- package/VERSION +1 -1
- package/package.json +4 -2
- package/src/lib/sproutsite/branding.ts +150 -0
- package/src/lib/sproutsite/hero-background.ts +61 -0
- package/src/lib/sproutsite/public-assets.ts +33 -0
- package/src/lib/sproutsite/remark-links.ts +4 -3
- package/src/lib/sproutsite/site-config.ts +211 -24
- package/src/lib/sproutsite/sitemap.ts +2 -2
- package/src/lib/sproutsite/types.ts +8 -9
- package/src/lib/sproutsite/urls.ts +3 -3
- package/src/lib/sproutsite/validation.ts +4 -1
- package/src/package/config.ts +25 -8
- package/src/package/content.ts +25 -1
- package/src/package/manifest.ts +5 -10
- package/src/package/page.astro +6 -3
- package/src/package/starter-assets/README.md +85 -0
- package/src/package/starter-assets/manifest.json +95 -0
- package/src/package/starter-assets/public/LICENSE.txt +202 -0
- package/src/package/starter-assets/public/NOTICE.txt +10 -0
- package/src/package/starter-assets/public/branding/apple-touch-icon.png +0 -0
- package/src/package/starter-assets/public/branding/favicon-16.png +0 -0
- package/src/package/starter-assets/public/branding/favicon-32.png +0 -0
- package/src/package/starter-assets/public/branding/favicon-48.png +0 -0
- package/src/package/starter-assets/public/branding/favicon.ico +0 -0
- package/src/package/starter-assets/public/branding/favicon.svg +1 -0
- package/src/package/starter-assets/public/branding/icon-192.png +0 -0
- package/src/package/starter-assets/public/branding/icon-512.png +0 -0
- package/src/package/starter-assets/public/branding/logo-light.svg +1 -0
- package/src/package/starter-assets/public/branding/logo.svg +1 -0
- package/src/package/starter-assets/public/branding/sharing-image.png +0 -0
- package/src/package/starter-assets/public/images/hero.jpg +0 -0
- package/src/package/starter-assets/sources/hero.svg +12 -0
- package/src/package/starter-assets/sources/sharing-image.svg +18 -0
- package/src/themes/default/branding.ts +53 -0
- package/src/themes/default/components/atoms/BrandLogo/BrandLogo.astro +49 -12
- package/src/themes/default/components/atoms/BrandLogo/BrandLogo.css +28 -0
- package/src/themes/default/components/atoms/HeroBackground/HeroBackground.astro +52 -0
- package/src/themes/default/components/atoms/HeroBackground/HeroBackground.css +23 -0
- package/src/themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.astro +8 -5
- package/src/themes/default/components/organisms/BlogIndex/BlogIndex.astro +16 -13
- package/src/themes/default/components/organisms/BlogPost/BlogPost.astro +1 -1
- package/src/themes/default/components/organisms/Footer/Footer.astro +2 -2
- package/src/themes/default/components/organisms/Footer/Footer.css +3 -1
- package/src/themes/default/components/organisms/Header/Header.astro +4 -4
- package/src/themes/default/components/organisms/Header/Header.css +7 -1
- package/src/themes/default/components/organisms/Hero/Hero.astro +12 -13
- package/src/themes/default/components/organisms/Hero/Hero.css +7 -18
- package/src/themes/default/components/organisms/PageTitle/PageTitle.astro +19 -0
- package/src/themes/default/layouts/ErrorPage/ErrorPage.astro +7 -6
- package/src/themes/default/layouts/PageLayout/PageLayout.astro +26 -35
- package/src/themes/default/styles/theme.css +1 -0
- package/src/themes/default/assets/hero-waves.svg +0 -41
package/README.md
CHANGED
|
@@ -131,8 +131,6 @@ export async function getStaticPaths() {
|
|
|
131
131
|
name: My website
|
|
132
132
|
url: https://example.com
|
|
133
133
|
base: /
|
|
134
|
-
language: en
|
|
135
|
-
locales: [en]
|
|
136
134
|
header:
|
|
137
135
|
links:
|
|
138
136
|
- label: Home
|
|
@@ -142,6 +140,11 @@ footer:
|
|
|
142
140
|
links:
|
|
143
141
|
- label: Home
|
|
144
142
|
href: /
|
|
143
|
+
i18n:
|
|
144
|
+
locale: en
|
|
145
|
+
defaultLocale: en
|
|
146
|
+
locales:
|
|
147
|
+
- en
|
|
145
148
|
```
|
|
146
149
|
|
|
147
150
|
Replace `name`, `url`, and the footer copy with your own details. `url` is your production origin, even during local development. A visible Sproutsite attribution is optional. Set `base` if the website will be hosted under a subpath, for example `/demo/`.
|
|
@@ -266,7 +269,7 @@ pages/
|
|
|
266
269
|
|
|
267
270
|
`page.yaml` requires a non-empty `title` and `description`. Both values are used for HTML metadata: `title` becomes the `<title>` tag and `description` becomes the meta description. Without `url`, its directory becomes the URL directly: `faq/page.yaml` becomes `/faq/`; a deeper `services/monitoring/page.yaml` becomes `/services/monitoring/`. The optional single URL segment `url` lets an English source path retain a localized public URL: `documentation/page.yaml` with `url: dokumentation` produces `/dokumentation/`. URL segments of parent pages are also considered for child pages.
|
|
268
271
|
|
|
269
|
-
A `hero.md` activates the shared hero and requires a frontmatter `title`, rendered as the visible `h1`. `titleHighlight` may select one text fragment from that title for the theme highlight. `hero
|
|
272
|
+
A `hero.md` activates the shared hero and requires a frontmatter `title`, rendered as the visible `h1`. `titleHighlight` may select one text fragment from that title for the theme highlight. `hero.classes` in `site.yaml` may optionally set up to eight theme classes for each hero and for the H1 fallback view without `hero.md`. A `classes` list in an individual `hero.md` completely overrides that global list; `classes: null` removes global classes for that hero. Classes must begin with `ss-`, for example `ss-hero--visual`, so a theme can add gradients, overlays, or textures. Global `hero.background-image` in `site.yaml` optionally names a public-root SVG or raster path such as `/backgrounds/hero-waves.svg`. Local `background-image` in `hero.md` overrides it with a public-root path or a relative local image; omission inherits the global setting and `null` disables it. Public paths receive `base` once. Imported raster images are optimized, SVGs and public files are preserved. Without either image setting, no background image is rendered and CSS gradients remain. Classes and images are independent: `classes: null` does not disable a global image. `claim` adds a prominent line below the title. `actions` optionally defines one or two Button-based calls to action with `label`, `href`, and `variant: primary|secondary`; `tagline` adds a short line below them. If these settings are omitted, the hero receives no additional image or actions. Delete the file to render `page.yaml.title` as a compact visible H1 fallback above the sections; it still receives global `hero.classes` and `hero.background-image`. Sections must be named `NN-name.md`, begin with an `h2`, and may set `tone: default`, `muted`, or `brand` in frontmatter. By default, `ss-section__content` constrains content to a readable width. `fullWidth: true` in section frontmatter removes this inner constraint; the shared outer `site-shell` and Markdown typography remain active. For numbered page and blog sections, `tone` also accepts an object with both `odd` and `even`. Each value is `default`, `muted`, or `brand`. The numeric filename prefix selects the tone, including translated files; it does not depend on the section's position in the page. Scalar tones remain fixed, and omitting `tone` still means `default`. Heroes only accept scalar tones. Use a YAML mapping, not a list:
|
|
270
273
|
|
|
271
274
|
```yaml
|
|
272
275
|
tone:
|
|
@@ -296,7 +299,9 @@ tagline: A short supporting claim.
|
|
|
296
299
|
---
|
|
297
300
|
```
|
|
298
301
|
|
|
299
|
-
|
|
302
|
+
`site.yaml` is the shared base. Optional `site.<locale>.yaml` files override individual object fields; arrays replace the entire inherited list. Omitted fields inherit the base values. Production URL, base path, default locale and enabled locale list remain shared. The base `i18n.locale` matches `i18n.defaultLocale`; locale files may set their own `i18n.locale`. The default locale is explicit and does not depend on list order. Legacy `language`/`locales`, `links.externalNewTab`/`externalIcon` and flat blog settings remain readable, but do not mix old and new spellings within a configuration layer.
|
|
303
|
+
|
|
304
|
+
English and German content can be maintained in the same project. Configure `i18n: { locale: en, defaultLocale: en, locales: [en, de] }` in `site.yaml`, add `site.de.yaml` with `i18n.locale: de` and German navigation, and add translated `page.de.yaml`, `hero.de.md`, and numbered `.de.md`/`.de.mdx` sections. Add `src/pages/de/[...slug].astro` using the same page component and an async `getStaticPaths()` wrapper that calls `getSproutsiteStaticPaths('de')`. Each locale uses its own copy and optional URL segments; translations are not generated automatically. Keep section numbers aligned between languages.
|
|
300
305
|
|
|
301
306
|
To deliberately remove global hero classes, use:
|
|
302
307
|
|
|
@@ -466,7 +471,7 @@ Use `class="ss-link--icon-only"` on links that display only an icon, together wi
|
|
|
466
471
|
|
|
467
472
|
Any link with `target="_blank"` must include both `noopener` and `noreferrer` in `rel`, even for same-origin destinations. Button and Markdown rendering preserve other relationship tokens while adding these protections. The repository's `npm run build` verifies all generated HTML pages and reports unsafe native anchors with their file and destination. This requirement also applies when automatic external new tabs are disabled and a new tab is explicitly requested.
|
|
468
473
|
|
|
469
|
-
Theme components use native `<a>` elements. External HTTP(S) links receive `target="_blank"` and `rel="noopener noreferrer"` by default, including Markdown reference/autolinks and header/footer links. Set `links.
|
|
474
|
+
Theme components use native `<a>` elements. External HTTP(S) links receive `target="_blank"` and `rel="noopener noreferrer"` by default, including Markdown reference/autolinks and header/footer links. Set `links.external.newTab: false` in `site.yaml` to retain native same-tab behavior for automatically handled links. Explicit Button `target`/`rel` props remain available. External means a different origin from the validated production URL, including in preview builds. Internal/same-origin links, fragments, `mailto:` and `tel:` retain their normal behavior. Links are underlined only on hover. Set `links.external.icon: true` to add a compact CSS-only Lucide arrow to external, email and telephone links; omission means no arrows. The two settings are independent and both are enabled in this demo's base configuration and inherited by German. No Link component or browser-side anchor rewriting is needed.
|
|
470
475
|
|
|
471
476
|
`ContentTable` wraps exactly one Markdown table in an MDX section. Its required `caption` becomes a native table caption. Optional props are `variant="plain|striped"`, `density="comfortable|compact"`, a boolean `wide` flag, and a one-based `highlight={2}` body-row index. Keep blank lines between the component tags and Markdown table. Column alignment uses standard Markdown colons. `wide` preserves a minimum table width of 60rem inside a keyboard-focusable horizontal scroll region.
|
|
472
477
|
|
|
@@ -591,7 +596,7 @@ The dev server deliberately starts with `--force`, so changes to Content Collect
|
|
|
591
596
|
The running demo documents itself at `/documentation/` (German: `/de/dokumentation/`): it contains setup, the content contract, layout components, theme, checks, and local package use. The visible [showcase](https://sproutsite.dev/showcase/) instead collects component examples.
|
|
592
597
|
The [blog](https://sproutsite.dev/blog/) is a small, file-based project journal. Each article lives in a `YYYY-MM-DD.article-slug/` directory in `src/content/blog/` and uses the same `page.yaml`, `hero.md`, and numbered sections as a normal page. `page.yaml` validates the title, description, date, local card image, and alternative text; the date prefix orders source directories while the URL only uses `article-slug`. Astro generates the overview and article routes from the collection, and every section supports the usual tones and documented MDX components.
|
|
593
598
|
|
|
594
|
-
The optional `blog` setting in `site.yaml` accepts `title`, `eyebrow`, `description`, and `heading` (all non-empty strings) to customize the blog overview. The demo configures English overview copy in `site.yaml` and German copy in `site.de.yaml`. Without this setting, the theme supplies neutral, localized fallback text. Article links use “Learn more” or “Mehr erfahren” and include the article title in their accessible name.
|
|
599
|
+
The optional `blog` setting in `site.yaml` accepts `hero.title`, `hero.eyebrow`, `hero.description`, and `articles.heading` (all non-empty strings) to customize the blog overview. The demo configures English overview copy in `site.yaml` and German copy in `site.de.yaml`. Without this setting, the theme supplies neutral, localized fallback text. Article links use “Learn more” or “Mehr erfahren” and include the article title in their accessible name.
|
|
595
600
|
|
|
596
601
|
English articles use `page.yaml`, `hero.md`, and numbered sections; their German counterparts use `page.de.yaml`, `hero.de.md`, and `.de.mdx` sections in the same article directory. Each pair keeps its publication date, image, and slug; titles, descriptions, alternative text, heroes, and body copy are maintained separately. `/blog/` and `/de/blog/` list their respective language versions. Dates use the site's language and UTC so a date-only publication value does not shift on hosts in another time zone.
|
|
597
602
|
|
|
@@ -636,9 +641,42 @@ Leave `PRIVACY_LOG_RETENTION_DAYS` empty until a time-based policy is implemente
|
|
|
636
641
|
|
|
637
642
|
### Logo and icons
|
|
638
643
|
|
|
639
|
-
|
|
644
|
+
Keep your own prepared branding files under `public/branding/` and configure them in `src/content/site.yaml`. This follows [Astro's public-file conventions](https://docs.astro.build/en/guides/images/#images-in-public): files are copied unchanged, not optimised. Do not edit installed package files.
|
|
645
|
+
|
|
646
|
+
```yaml
|
|
647
|
+
branding:
|
|
648
|
+
logo:
|
|
649
|
+
src: /branding/logo.svg
|
|
650
|
+
srcOnDark: /branding/logo-light.svg
|
|
651
|
+
width: 180
|
|
652
|
+
height: 48
|
|
653
|
+
showName: false
|
|
654
|
+
icons:
|
|
655
|
+
favicon: /branding/favicon.svg
|
|
656
|
+
shortcut: /branding/favicon.ico
|
|
657
|
+
appleTouch: /branding/apple-touch-icon.png
|
|
658
|
+
app192: /branding/icon-192.png
|
|
659
|
+
app512: /branding/icon-512.png
|
|
660
|
+
sharingImage:
|
|
661
|
+
src: /branding/sharing-image.png
|
|
662
|
+
alt: A description of your website preview
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
All branding sections are optional. Logos accept SVG, PNG, JPEG or WebP; `width` and `height` define the intended display box in pixels, scaled proportionally on narrow screens. `showName: true` places the configured website name beside a symbol using the heading typography; false displays a complete image wordmark with the website name as its accessible name. Without a logo, the name appears as text. `srcOnDark` is optional and used on the hero navbar, mobile menu and footer; the docked navbar uses `src`. Optional `branding.footerLogo` accepts the same fields and otherwise inherits `logo`.
|
|
666
|
+
|
|
667
|
+
`favicon` accepts SVG, PNG or ICO; `shortcut` accepts ICO. Apple touch and app icons require PNGs of exactly 180×180, 192×192 and 512×512 respectively. Omitted icon fields use neutral document icons, independently of the website name. `sharingImage` accepts PNG, JPEG or WebP and a non-empty alternative text; its real dimensions and absolute URL are emitted in Open Graph and Twitter metadata for any website. Without it, no sharing image is advertised. Per-page sharing-image overrides are not implemented.
|
|
668
|
+
|
|
669
|
+
Paths are public-root-relative, with no `public`, language or deployment prefix. Sproutsite applies `base` once. Configured paths must be existing files within `public/`; remote URLs, traversal, query strings and fragments are rejected. Astro verifies image formats and icon dimensions during startup/build. Localized `site.*.yaml` files inherit branding from `site.yaml` and may override individual nested fields, including image paths and translated `sharingImage.alt`. The shared `/site.webmanifest` uses the main configuration. Restart the dev server after configuration or branding-file changes. No runtime service, offline mode or consumer asset generator is added.
|
|
670
|
+
|
|
671
|
+
The Sproutsite demo uses the same configuration with its own files in `public/branding/`. Source artwork remains in `src/themes/default/assets/branding/`; `npm run branding:generate` reproduces it and synchronizes the demo's public copies, then regenerates the neutral starter set.
|
|
672
|
+
|
|
673
|
+
### Copyable starter assets
|
|
674
|
+
|
|
675
|
+
`src/package/starter-assets/public/` is the single neutral source for new websites and the theme's fallback icons. It contains a document-symbol logo, light/dark-compatible variant, SVG/ICO/PNG favicons, Apple/app icons, a 1200×630 sharing image and a 1920×1080 hero example. These first-party SVG sources and their deterministic raster derivatives are licensed under Apache-2.0, with the unchanged full license and an attribution notice included in the copyable directory. The product demo assets are separate.
|
|
676
|
+
|
|
677
|
+
Resolve the public `sproutsite/starter-assets` package export to find `manifest.json`. Its version-1 contract includes `publicDirectory`, exact file paths and SHA-256 hashes, a ready-to-merge `branding` object, English/German sharing-image alternative text, and an optional hero-image copy mapping for Astro's local `image()` schema. See [the starter asset contract](src/package/starter-assets/README.md) for a Node/TypeScript example. The asset set is included in the npm archive; no additional package or runtime service is needed.
|
|
640
678
|
|
|
641
|
-
`
|
|
679
|
+
Run `npm run starter-assets:generate` after editing `public/branding/logo.svg` or `sources/*.svg` within the starter directory. Generation requires the repository's development dependencies and is not part of a consumer build. The separate `create-sproutsite` generator must vendor a reviewed snapshot before its release, copy binaries unchanged, preserve LICENSE.txt/NOTICE.txt and fill in the site's configuration. It must not fetch assets at user generation time, so `--no-install` remains functional. That generator update is maintained by its own agent; this repository does not claim that the published initializer already ships these files. See [the handoff](docs/create-sproutsite-starter-handoff.md).
|
|
642
680
|
|
|
643
681
|
Brand colors are separate `--color-brand-*` tokens in `styles/foundation/tokens.css`; the existing semantic UI palette is unchanged. Run `npm run branding:generate` after changing the vector geometry or brand tokens, then `npm run format`. The TypeScript generator uses `fontkit` and `sharp` only during development. Its local source font is `scripts/assets/nunito-variable.ttf` from the [official Nunito distribution](https://github.com/google/fonts/tree/main/ofl/nunito), covered by the adjacent SIL Open Font License. Generated assets are committed and ordinary builds do not regenerate or download them.
|
|
644
682
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -57,15 +57,17 @@ No installed dependency license or NOTICE file was removed, overwritten, or reli
|
|
|
57
57
|
|
|
58
58
|
## Project branding and hero artwork
|
|
59
59
|
|
|
60
|
+
The demo copies of the project's icon, favicon, app icons and social card in `public/branding/` are unchanged copies of the corresponding authorized artwork below. The demo configures them through `site.yaml`, using the same public-file workflow as consumer sites. The separate neutral starter set under `src/package/starter-assets/` is first-party vector artwork and deterministic Sharp-derived raster/ICO files, licensed under Apache-2.0. Its document icon, abstract landscape and generic browser preview contain no Sproutsite logo, third-party artwork, embedded fonts or AI-generated imagery. The original document icon was moved from the former theme defaults directory; the theme imports the same canonical starter files directly. The copyable `public/` subtree contains the unchanged official Apache-2.0 text in LICENSE.txt and its attribution in NOTICE.txt. Keep those notices with redistributed starter assets; this adds no visible footer attribution requirement.
|
|
61
|
+
|
|
60
62
|
On 2026-11-16, project maintainer Björn Hempel confirmed that the supplied logo reference and hero SVG were created with AI assistance and explicitly authorized making the following project artwork available under the Apache License, Version 2.0, to the extent he holds rights that he can license. The technical derivation is recorded below. No particular AI provider, model, or absence of third-party reference inputs is asserted by this confirmation.
|
|
61
63
|
|
|
62
64
|
| Asset scope | Recorded origin and derivation | Release status |
|
|
63
65
|
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
|
|
64
66
|
| `src/themes/default/assets/branding/icon.svg` and the other branding SVGs | Reconstructed and subsequently refined as vector artwork for Sproutsite from the maintainer's AI-created logo reference. `scripts/generate-branding.ts` contains the vector geometry and generation process. | Apache-2.0 under the maintainer's authorization stated above. |
|
|
65
67
|
| Favicons, app icons, and `social-card.png` in the same branding directory | Generated from the project's vector artwork by `npm run branding:generate`. | Apache-2.0 under the same authorization, including these derived files. |
|
|
66
|
-
| `
|
|
68
|
+
| `public/backgrounds/hero-waves.svg` | The maintainer supplied the AI-created `sproutsite-hero-waves.svg` for integration. The project subsequently adjusted its composition, gradients, and positioning. | Apache-2.0 under the maintainer's authorization stated above. |
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
The bundled branding scopes are included in the npm archive; the hero SVG now lives in the demo's public directory and is excluded from that archive. All three scopes remain covered by the root [LICENSE](LICENSE), with the project's attribution information in [NOTICE](NOTICE). Their use, modification, and redistribution follow Apache-2.0, including its applicable notice requirements. This records the maintainer's provenance statement and license grant; it does not assert exclusive copyright in AI output or independently certify third-party rights. Nunito and all other third-party materials retain their own licenses and applicable notices.
|
|
69
71
|
|
|
70
72
|
Copyright licensing of artwork and trademark rights are separate. Apache-2.0 Section 6 does not grant general trademark rights; this file adds no trademark restrictions or extra attribution obligations.
|
|
71
73
|
|
|
@@ -102,6 +104,6 @@ The following existing assets do not have a committed, asset-specific rights/pro
|
|
|
102
104
|
| PNGs in `src/content/pages/_assets/`, `src/content/pages/showcase/_assets/`, and `src/content/pages/documentation/_assets/` | Committed demo illustrations without an accompanying asset licensing record. | Record the source or generation provenance, relevant terms, and any third-party reference permissions for each illustration. |
|
|
103
105
|
| PNGs in `src/content/blog/_assets/` | AI-generated editorial illustrations; current prompts and provenance are recorded in `docs/assets/blog-images.md`. | Review applicable generation terms and artwork licensing; the branding authorization above does not automatically license these separate illustrations. |
|
|
104
106
|
|
|
105
|
-
The branding
|
|
107
|
+
The bundled branding assets are included by the current npm file list. The configurable hero SVG now belongs to the demo's public/backgrounds/ directory and is excluded from the npm archive. Their Apache-2.0 authorization remains recorded above. This authorization does not automatically license all demo illustrations or separate composite artwork incorporating the branding. Demo content images are excluded from the npm archive but remain relevant when publishing the repository's demo website. Removing the package's private flag or passing a packaging check does not itself establish asset rights.
|
|
106
108
|
|
|
107
109
|
No additional trademark policy, registration claim, or attribution obligation is introduced here. Apache-2.0 Section 6 governs its trademark-license scope; any later artwork licensing decision should be documented explicitly rather than inferred from the software license.
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.25
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sproutsite",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.25",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Björn Hempel",
|
|
6
6
|
"description": "Agent-ready, Markdown-first Static CMS powered by Astro and TypeScript.",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"./content": "./src/package/content.ts",
|
|
31
31
|
"./config": "./src/package/config.ts",
|
|
32
32
|
"./components": "./src/package/components.ts",
|
|
33
|
+
"./starter-assets": "./src/package/starter-assets/manifest.json",
|
|
33
34
|
"./page": "./src/package/page.astro",
|
|
34
35
|
"./package.json": "./package.json"
|
|
35
36
|
},
|
|
@@ -40,7 +41,8 @@
|
|
|
40
41
|
"postcss-selector-parser": "6.1.5"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
|
-
"branding:generate": "node --import tsx scripts/generate-branding.ts",
|
|
44
|
+
"branding:generate": "node --import tsx scripts/generate-branding.ts && npm run starter-assets:generate",
|
|
45
|
+
"starter-assets:generate": "node --import tsx scripts/generate-starter-assets.ts",
|
|
44
46
|
"dev": "astro dev --force",
|
|
45
47
|
"build": "npm run validate && astro build && node --import tsx scripts/verify-build.ts",
|
|
46
48
|
"build:demo": "SPROUTSITE_BASE=/demo/ npm run build",
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import {
|
|
4
|
+
publicAssetPath as assetPath,
|
|
5
|
+
publicAssetFile as publicBrandingFile,
|
|
6
|
+
publicImageMetadata as brandingImageMetadata,
|
|
7
|
+
} from './public-assets.js';
|
|
8
|
+
export { brandingImageMetadata };
|
|
9
|
+
|
|
10
|
+
// Paths refer to Astro's standard public directory, without a deployment base.
|
|
11
|
+
const logoSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
src: assetPath,
|
|
14
|
+
srcOnDark: assetPath.optional(),
|
|
15
|
+
width: z.number().int().positive().max(4096),
|
|
16
|
+
height: z.number().int().positive().max(4096),
|
|
17
|
+
showName: z.boolean().default(false),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
|
|
21
|
+
export const brandingSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
logo: logoSchema.optional(),
|
|
24
|
+
footerLogo: logoSchema.optional(),
|
|
25
|
+
icons: z
|
|
26
|
+
.object({
|
|
27
|
+
favicon: assetPath.optional(),
|
|
28
|
+
shortcut: assetPath.optional(),
|
|
29
|
+
appleTouch: assetPath.optional(),
|
|
30
|
+
app192: assetPath.optional(),
|
|
31
|
+
app512: assetPath.optional(),
|
|
32
|
+
})
|
|
33
|
+
.strict()
|
|
34
|
+
.optional(),
|
|
35
|
+
sharingImage: z
|
|
36
|
+
.object({
|
|
37
|
+
src: assetPath,
|
|
38
|
+
alt: z.string().trim().min(1),
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
.optional(),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
|
|
45
|
+
export type Branding = z.infer<typeof brandingSchema>;
|
|
46
|
+
export type BrandLogoConfig = z.infer<typeof logoSchema>;
|
|
47
|
+
|
|
48
|
+
function assets(branding: Branding) {
|
|
49
|
+
return [
|
|
50
|
+
...(['logo', 'footerLogo'] as const).flatMap((key) => {
|
|
51
|
+
const logo = branding[key];
|
|
52
|
+
return logo
|
|
53
|
+
? [
|
|
54
|
+
{
|
|
55
|
+
field: `${key}.src`,
|
|
56
|
+
src: logo.src,
|
|
57
|
+
formats: ['svg', 'png', 'jpeg', 'webp'],
|
|
58
|
+
},
|
|
59
|
+
...(logo.srcOnDark
|
|
60
|
+
? [
|
|
61
|
+
{
|
|
62
|
+
field: `${key}.srcOnDark`,
|
|
63
|
+
src: logo.srcOnDark,
|
|
64
|
+
formats: ['svg', 'png', 'jpeg', 'webp'],
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
: []),
|
|
68
|
+
]
|
|
69
|
+
: [];
|
|
70
|
+
}),
|
|
71
|
+
...Object.entries(branding.icons ?? {}).map(([key, src]) => ({
|
|
72
|
+
field: `icons.${key}`,
|
|
73
|
+
src,
|
|
74
|
+
formats:
|
|
75
|
+
key === 'favicon'
|
|
76
|
+
? ['svg', 'png', 'ico']
|
|
77
|
+
: key === 'shortcut'
|
|
78
|
+
? ['ico']
|
|
79
|
+
: ['png'],
|
|
80
|
+
})),
|
|
81
|
+
...(branding.sharingImage
|
|
82
|
+
? [
|
|
83
|
+
{
|
|
84
|
+
field: 'sharingImage.src',
|
|
85
|
+
src: branding.sharingImage.src,
|
|
86
|
+
formats: ['png', 'jpeg', 'webp'],
|
|
87
|
+
},
|
|
88
|
+
]
|
|
89
|
+
: []),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Fast, synchronous checks also run through npm run validate. */
|
|
94
|
+
export function validateBrandingFiles(
|
|
95
|
+
branding: Branding | undefined,
|
|
96
|
+
root: string,
|
|
97
|
+
source: string,
|
|
98
|
+
): void {
|
|
99
|
+
for (const asset of assets(branding ?? {})) {
|
|
100
|
+
try {
|
|
101
|
+
publicBrandingFile(asset.src, root);
|
|
102
|
+
const extension = extname(asset.src)
|
|
103
|
+
.slice(1)
|
|
104
|
+
.toLowerCase()
|
|
105
|
+
.replace('jpg', 'jpeg');
|
|
106
|
+
if (!asset.formats.includes(extension))
|
|
107
|
+
throw new Error(`expected ${asset.formats.join(', ')}`);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`Invalid ${source}: branding.${asset.field} (${asset.src}): ${error instanceof Error ? error.message : String(error)}`,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Astro's image reader verifies file contents and required app-icon dimensions. */
|
|
117
|
+
export async function validateBrandingImages(
|
|
118
|
+
branding: Branding | undefined,
|
|
119
|
+
root = process.cwd(),
|
|
120
|
+
): Promise<void> {
|
|
121
|
+
for (const asset of assets(branding ?? {})) {
|
|
122
|
+
try {
|
|
123
|
+
const metadata = await brandingImageMetadata(asset.src, root);
|
|
124
|
+
const extension = extname(asset.src)
|
|
125
|
+
.slice(1)
|
|
126
|
+
.toLowerCase()
|
|
127
|
+
.replace('jpg', 'jpeg');
|
|
128
|
+
// Astro reports JPEG metadata as jpg, regardless of .jpg/.jpeg.
|
|
129
|
+
const format = metadata.format === 'jpg' ? 'jpeg' : metadata.format;
|
|
130
|
+
if (format !== extension)
|
|
131
|
+
throw new Error('image content must match the file extension');
|
|
132
|
+
if (!asset.formats.includes(format))
|
|
133
|
+
throw new Error(
|
|
134
|
+
'file content does not match the allowed image formats',
|
|
135
|
+
);
|
|
136
|
+
const sizes: Record<string, number> = {
|
|
137
|
+
'icons.appleTouch': 180,
|
|
138
|
+
'icons.app192': 192,
|
|
139
|
+
'icons.app512': 512,
|
|
140
|
+
};
|
|
141
|
+
const size = sizes[asset.field];
|
|
142
|
+
if (size && (metadata.width !== size || metadata.height !== size))
|
|
143
|
+
throw new Error(`expected ${size} × ${size} pixels`);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Invalid branding.${asset.field} (${asset.src}): ${error instanceof Error ? error.message : String(error)}`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
2
|
+
import type { ImageMetadata } from 'astro';
|
|
3
|
+
import {
|
|
4
|
+
publicAssetFile,
|
|
5
|
+
publicAssetPath,
|
|
6
|
+
publicImageMetadata,
|
|
7
|
+
} from './public-assets.js';
|
|
8
|
+
|
|
9
|
+
const formats = ['svg', 'png', 'jpg', 'jpeg', 'webp', 'avif'];
|
|
10
|
+
export const publicHeroImage = publicAssetPath.refine(
|
|
11
|
+
(src) => formats.includes(extname(src).slice(1).toLowerCase()),
|
|
12
|
+
'must be a public SVG, PNG, JPEG, WebP or AVIF image',
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export type HeroBackground = ImageMetadata | string | null | undefined;
|
|
16
|
+
|
|
17
|
+
export function isSvgHeroImage(image: HeroBackground): boolean {
|
|
18
|
+
return typeof image === 'string'
|
|
19
|
+
? image.toLowerCase().endsWith('.svg')
|
|
20
|
+
: image?.format === 'svg';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Undefined inherits; null explicitly disables a global default. */
|
|
24
|
+
export function selectHeroBackground(
|
|
25
|
+
local: HeroBackground,
|
|
26
|
+
global: string | undefined,
|
|
27
|
+
): HeroBackground {
|
|
28
|
+
return local === undefined ? global : local;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function validateHeroBackground(
|
|
32
|
+
src: string | null | undefined,
|
|
33
|
+
source: string,
|
|
34
|
+
root = process.cwd(),
|
|
35
|
+
): void {
|
|
36
|
+
if (src == null) return;
|
|
37
|
+
try {
|
|
38
|
+
publicHeroImage.parse(src);
|
|
39
|
+
publicAssetFile(src, root);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Invalid ${source}: hero.background-image (${src}): ${error instanceof Error ? error.message : String(error)}`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function validateHeroBackgroundImage(
|
|
48
|
+
src: string | null | undefined,
|
|
49
|
+
root = process.cwd(),
|
|
50
|
+
): Promise<void> {
|
|
51
|
+
if (src == null) return;
|
|
52
|
+
const metadata = await publicImageMetadata(src, root);
|
|
53
|
+
const extension = extname(src)
|
|
54
|
+
.slice(1)
|
|
55
|
+
.toLowerCase()
|
|
56
|
+
.replace('jpeg', 'jpg');
|
|
57
|
+
if (metadata.format !== extension)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Invalid hero.background-image (${src}): image content must match its SVG or raster extension`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { imageMetadata } from 'astro/assets/utils';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
export const publicAssetPath = z.string().refine(
|
|
7
|
+
(value) =>
|
|
8
|
+
/^\/(?!\/)[A-Za-z0-9_./-]+$/.test(value) &&
|
|
9
|
+
value
|
|
10
|
+
.slice(1)
|
|
11
|
+
.split('/')
|
|
12
|
+
.every((part) => part && part !== '.' && part !== '..'),
|
|
13
|
+
'must be a root-relative public file path without a base, query, fragment or traversal',
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export function publicAssetFile(src: string, root = process.cwd()): string {
|
|
17
|
+
if (!publicAssetPath.safeParse(src).success)
|
|
18
|
+
throw new Error(`Unsafe public asset path: ${src}`);
|
|
19
|
+
const directory = realpathSync(resolve(root, 'public'));
|
|
20
|
+
const file = realpathSync(resolve(directory, `.${src}`));
|
|
21
|
+
const within = relative(directory, file);
|
|
22
|
+
if (
|
|
23
|
+
within.startsWith(`..${sep}`) ||
|
|
24
|
+
within === '..' ||
|
|
25
|
+
!statSync(file).isFile()
|
|
26
|
+
)
|
|
27
|
+
throw new Error(`Asset must be a file inside public/: ${src}`);
|
|
28
|
+
return file;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function publicImageMetadata(src: string, root = process.cwd()) {
|
|
32
|
+
return imageMetadata(readFileSync(publicAssetFile(src, root)), src);
|
|
33
|
+
}
|
|
@@ -6,12 +6,13 @@ import type { SiteConfig } from './types.js';
|
|
|
6
6
|
export function remarkContentLinks(site: SiteConfig) {
|
|
7
7
|
return (tree: Root, file: { path?: string }) => {
|
|
8
8
|
const locale =
|
|
9
|
-
site.locales.find((language) =>
|
|
9
|
+
site.i18n.locales.find((language) =>
|
|
10
10
|
['md', 'mdx'].some((extension) =>
|
|
11
11
|
file.path?.endsWith(`.${language}.${extension}`),
|
|
12
12
|
),
|
|
13
|
-
) ??
|
|
14
|
-
|
|
13
|
+
) ??
|
|
14
|
+
(site.i18n.locales.includes('en') ? 'en' : site.i18n.defaultLocale);
|
|
15
|
+
const documentSite = { ...site, i18n: { ...site.i18n, locale } };
|
|
15
16
|
visit(tree, 'link', (node) => {
|
|
16
17
|
node.url = contentHref(node.url, documentSite);
|
|
17
18
|
});
|