sproutsite 0.5.27 → 0.5.28

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 CHANGED
@@ -508,6 +508,26 @@ The optional list accepts existing project-relative `.css` files. The complete d
508
508
 
509
509
  A small build-time Vite CSS entry imports the unchanged theme entry followed by the configured files. Astro/Vite retain responsibility for compilation, asset URLs and HMR; no stylesheet registry or browser script is added.
510
510
 
511
+ To replace page areas with website-owned Astro components, use the separate optional `components` setting:
512
+
513
+ ```ts
514
+ export default defineConfig(
515
+ createSproutsiteConfig({
516
+ styles: ['./src/styles/custom.css'],
517
+ components: {
518
+ Header: './src/components/Header.astro',
519
+ Footer: './src/components/Footer.astro',
520
+ },
521
+ }),
522
+ );
523
+ ```
524
+
525
+ Only `Header` and `Footer` are supported. Paths must be existing project-relative `.astro` files; unknown keys and invalid paths fail configuration. Omitted slots retain their defaults independently. Both components receive `site` (the resolved active-locale configuration) and `route` (translated content path without locale/base prefixes). Use `HeaderProps` or `FooterProps` from `sproutsite` as the component's Props type; no other required props are supplied. Error pages also use these slots; landing pages still omit the header. The shared layout retains metadata, main content, fonts, colour variables and skip link.
526
+
527
+ The public `DefaultHeader` and `DefaultFooter` exports from `sproutsite/components` always target the supplied implementations. A replacement can delegate to them without recursively resolving itself. Completely new markup requires the website team to implement responsive behavior, locale/base-aware links, active navigation and accessibility. Local files survive package updates, but their compatibility still needs review. This is not a general theme loader or an extension of the allowed MDX imports. See the [header/footer guide](https://sproutsite.dev/documentation/getting-started/your-website/header-and-footer/).
528
+
529
+ Internally, the shared layout uses two private [Node package imports](https://nodejs.org/api/packages.html#subpath-imports) with default targets. Configured replacements use standard [Vite aliases](https://vite.dev/config/shared-options.html#resolve-alias), then Astro compiles the selected files normally. There is no browser-side resolver or component registry. Website components must use the public default exports rather than the private `#sproutsite/` aliases.
530
+
511
531
  The entry point for the default theme is `src/themes/default/styles/theme.css`. It documents the import order and remains the only central import. Global foundations live in `styles/foundation/`, semantic content variants in `styles/themes/`. Components follow Atomic Design: `atoms/`, `molecules/`, `organisms/`, and `layout/` for technical layout primitives. Every visible building block is organized locally as a pair, for example `components/organisms/Header/Header.astro` and `components/organisms/Header/Header.css`; `layouts/PageLayout/` follows the same pattern. Theme-owned classes begin with `ss-`, for example `ss-header` and `ss-header__inner`. The default theme is named `sproutsite`, intentionally light, and centrally defines semantic DaisyUI tokens, font sizes, spacing, radii, and shadows in its theme and foundation files.
512
532
 
513
533
  Another theme can replace these components and the technical CSS integration without migrating Markdown or YAML. This is not yet a configurable theme loader and deliberately does not claim every UI library can be switched through a setting.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.27
1
+ 0.5.28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sproutsite",
3
- "version": "0.5.27",
3
+ "version": "0.5.28",
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.",
@@ -34,6 +34,10 @@
34
34
  "./page": "./src/package/page.astro",
35
35
  "./package.json": "./package.json"
36
36
  },
37
+ "imports": {
38
+ "#sproutsite/header": "./src/themes/default/components/organisms/Header/Header.astro",
39
+ "#sproutsite/footer": "./src/themes/default/components/organisms/Footer/Footer.astro"
40
+ },
37
41
  "engines": {
38
42
  "node": ">=24.0.0"
39
43
  },
@@ -30,6 +30,14 @@ export type HeaderItem =
30
30
  | { type: 'separator' }
31
31
  | { type: 'language-switcher' };
32
32
 
33
+ /** Shared layout data. route has translated segments but no locale/base prefix. */
34
+ export interface LayoutComponentProps {
35
+ site: SiteConfig;
36
+ route: string;
37
+ }
38
+ export type HeaderProps = LayoutComponentProps;
39
+ export type FooterProps = LayoutComponentProps;
40
+
33
41
  export interface SiteConfig {
34
42
  branding?: Branding;
35
43
  colors?: SiteColors;
@@ -0,0 +1,56 @@
1
+ import { statSync } from 'node:fs';
2
+ import { extname, isAbsolute, resolve } from 'node:path';
3
+
4
+ /** The shared layout exposes these two slots only, not an arbitrary registry. */
5
+ export interface ComponentOverrides {
6
+ Header?: string;
7
+ Footer?: string;
8
+ }
9
+
10
+ /** Vite aliases select local Astro files at build time; Node imports supply defaults. */
11
+ export function resolveComponentAliases(
12
+ components: ComponentOverrides = {},
13
+ root = process.cwd(),
14
+ ) {
15
+ if (
16
+ typeof components !== 'object' ||
17
+ components === null ||
18
+ Array.isArray(components)
19
+ )
20
+ throw new Error(
21
+ 'Sproutsite components must be an object with optional Header and Footer paths.',
22
+ );
23
+ const aliases: { find: string; replacement: string }[] = [];
24
+ for (const [slot, path] of Object.entries(components)) {
25
+ if (slot !== 'Header' && slot !== 'Footer')
26
+ throw new Error(
27
+ `Invalid Sproutsite components.${slot}: only Header and Footer can be replaced.`,
28
+ );
29
+ if (path === undefined) continue;
30
+ if (
31
+ typeof path !== 'string' ||
32
+ path.trim() === '' ||
33
+ isAbsolute(path) ||
34
+ /^[a-z][a-z\d+.-]*:/i.test(path) ||
35
+ /[?#\0\r\n]/.test(path) ||
36
+ extname(path) !== '.astro'
37
+ )
38
+ throw new Error(
39
+ `Invalid Sproutsite components.${slot}: expected a project-relative .astro file, for example ./src/components/${slot}.astro.`,
40
+ );
41
+ const absolute = resolve(root, path);
42
+ try {
43
+ if (!statSync(absolute).isFile())
44
+ throw new Error('not a regular file');
45
+ } catch {
46
+ throw new Error(
47
+ `Invalid Sproutsite components.${slot}: Astro file does not exist or is not a regular file: ${path}`,
48
+ );
49
+ }
50
+ aliases.push({
51
+ find: `#sproutsite/${slot.toLowerCase()}`,
52
+ replacement: absolute.replaceAll('\\', '/'),
53
+ });
54
+ }
55
+ return aliases;
56
+ }
@@ -18,3 +18,5 @@ export { default as Accordion } from '../themes/default/components/molecules/Acc
18
18
  export { default as AccordionItem } from '../themes/default/components/molecules/AccordionItem/AccordionItem.astro';
19
19
  export { default as Column } from '../themes/default/components/layout/Column/Column.astro';
20
20
  export { default as Columns } from '../themes/default/components/layout/Columns/Columns.astro';
21
+ export { default as DefaultHeader } from '../themes/default/components/organisms/Header/Header.astro';
22
+ export { default as DefaultFooter } from '../themes/default/components/organisms/Footer/Footer.astro';
@@ -21,15 +21,22 @@ import { validateBrandingImages } from '../lib/sproutsite/branding.js';
21
21
  import { validateHeroBackgroundImage } from '../lib/sproutsite/hero-background.js';
22
22
  import { colorStyles } from '../themes/default/colors.js';
23
23
  import { createStylesPlugin } from './styles.js';
24
+ import {
25
+ resolveComponentAliases,
26
+ type ComponentOverrides,
27
+ } from './component-overrides.js';
24
28
 
25
29
  export interface SproutsiteConfigOptions {
26
30
  /** Project-relative CSS files, loaded after the default theme in list order. */
27
31
  styles?: readonly string[];
32
+ /** Optional website-owned Header/Footer Astro components. */
33
+ components?: ComponentOverrides;
28
34
  }
29
35
 
30
36
  /** Returns the Astro configuration required by the default Sproutsite theme. */
31
37
  export function createSproutsiteConfig(options: SproutsiteConfigOptions = {}) {
32
38
  const stylesPlugin = createStylesPlugin(options.styles);
39
+ const componentAliases = resolveComponentAliases(options.components);
33
40
  validateSproutsiteContent();
34
41
  const site = loadSiteConfig();
35
42
  for (const locale of site.i18n.locales) {
@@ -168,7 +175,10 @@ export function createSproutsiteConfig(options: SproutsiteConfigOptions = {}) {
168
175
  },
169
176
  } satisfies AstroIntegration,
170
177
  ],
171
- vite: { plugins: [stylesPlugin, tailwindcss()] },
178
+ vite: {
179
+ plugins: [stylesPlugin, tailwindcss()],
180
+ resolve: { alias: componentAliases },
181
+ },
172
182
  markdown: {
173
183
  // A high-contrast Shiki theme keeps code comments readable in the
174
184
  // documentation as well as in regular content.
@@ -1,4 +1,10 @@
1
1
  export { createSproutsiteCollections } from './content.js';
2
2
  export { createSproutsiteConfig } from './config.js';
3
3
  export type { SproutsiteConfigOptions } from './config.js';
4
- export type { Link, SiteConfig, Tone } from '../lib/sproutsite/types.js';
4
+ export type {
5
+ Link,
6
+ SiteConfig,
7
+ Tone,
8
+ HeaderProps,
9
+ FooterProps,
10
+ } from '../lib/sproutsite/types.js';
@@ -6,15 +6,12 @@ import Icon from '../../atoms/Icon/Icon.astro';
6
6
  import LanguageSwitcher from '../../molecules/LanguageSwitcher/LanguageSwitcher.astro';
7
7
  import version from '../../../../../../VERSION?raw';
8
8
  import { t } from '../../../i18n/index.js';
9
- import type { SiteConfig } from '../../../../../lib/sproutsite/types.js';
9
+ import type { FooterProps } from '../../../../../lib/sproutsite/types.js';
10
10
  import {
11
11
  contentHref,
12
12
  externalLinkAttributes,
13
13
  } from '../../../../../lib/sproutsite/urls.js';
14
- interface Props {
15
- site: SiteConfig;
16
- route: string;
17
- }
14
+ type Props = FooterProps;
18
15
  const { site, route } = Astro.props;
19
16
  const language = site.i18n.locale === 'de' ? 'de' : 'en';
20
17
  const socialIcons = {
@@ -5,17 +5,14 @@ import Icon from '../../atoms/Icon/Icon.astro';
5
5
  import LanguageSwitcher from '../../molecules/LanguageSwitcher/LanguageSwitcher.astro';
6
6
  import type { ComponentProps } from 'astro/types';
7
7
  import { t } from '../../../i18n/index.js';
8
- import type { SiteConfig } from '../../../../../lib/sproutsite/types.js';
8
+ import type { HeaderProps } from '../../../../../lib/sproutsite/types.js';
9
9
  import { navigationCurrent } from './navigation.js';
10
10
  import {
11
11
  contentHref,
12
12
  externalLinkAttributes,
13
13
  } from '../../../../../lib/sproutsite/urls.js';
14
14
 
15
- interface Props {
16
- site: SiteConfig;
17
- route: string;
18
- }
15
+ type Props = HeaderProps;
19
16
  const { site, route } = Astro.props;
20
17
  const language = site.i18n.locale === 'de' ? 'de' : 'en';
21
18
  const hasLanguageSwitcher = site.header.links.some(
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  import '../../../../package/styles.css';
3
- import Header from '../../components/organisms/Header/Header.astro';
3
+ import Header from '#sproutsite/header';
4
4
  import { t } from '../../i18n/index.js';
5
- import Footer from '../../components/organisms/Footer/Footer.astro';
5
+ import Footer from '#sproutsite/footer';
6
6
  import type { SiteConfig } from '../../../../lib/sproutsite/types.js';
7
7
  import { canonicalUrl, withBase } from '../../../../lib/sproutsite/urls.js';
8
8
  import { resolveBranding } from '../../branding.js';