sproutsite 0.5.26 → 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 +32 -0
- package/VERSION +1 -1
- package/package.json +5 -1
- package/src/lib/sproutsite/types.ts +8 -0
- package/src/package/component-overrides.ts +56 -0
- package/src/package/components.ts +2 -0
- package/src/package/config.ts +19 -2
- package/src/package/index.ts +8 -1
- package/src/package/styles.css +4 -0
- package/src/package/styles.ts +60 -0
- package/src/themes/default/components/organisms/Footer/Footer.astro +2 -5
- package/src/themes/default/components/organisms/Header/Header.astro +2 -5
- package/src/themes/default/layouts/PageLayout/PageLayout.astro +3 -3
package/README.md
CHANGED
|
@@ -496,6 +496,38 @@ This MDX component requires the Sproutsite configuration: a small rehype transfo
|
|
|
496
496
|
|
|
497
497
|
The small reusable content and URL logic lives in `src/lib/sproutsite/`. It knows neither demo text nor Tailwind or DaisyUI classes. The default theme lives in `src/themes/default/` and includes the layout, header, hero, sections, and footer. DaisyUI is actively used there for navigation and theme elements.
|
|
498
498
|
|
|
499
|
+
For website-owned CSS, pass `styles` to `createSproutsiteConfig` in `astro.config.ts`:
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
export default defineConfig(
|
|
503
|
+
createSproutsiteConfig({ styles: ['./src/styles/custom.css'] }),
|
|
504
|
+
);
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
The optional list accepts existing project-relative `.css` files. The complete default theme loads first, followed by these files in list order, for all shared page layouts and locales. Missing files and invalid entries stop configuration. CSS imports, local assets and development updates use Astro/Vite; restart the dev server after changing the entry list. Omission or `styles: []` retains theme-only output. Use targeted unlayered rules for overrides such as `.ss-card { border-radius: 1.25rem; }`; normal cascade priorities and specificity still apply. Layered rules may lose to higher-priority DaisyUI or utility layers. Supported inline colour and typography settings remain in `site.yaml`. This option does not replace components or create theme inheritance. See the [small design changes guide](https://sproutsite.dev/documentation/getting-started/your-website/theme-overrides/).
|
|
508
|
+
|
|
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
|
+
|
|
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
|
+
|
|
499
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.
|
|
500
532
|
|
|
501
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.
|
|
1
|
+
0.5.28
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sproutsite",
|
|
3
|
-
"version": "0.5.
|
|
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';
|
package/src/package/config.ts
CHANGED
|
@@ -20,9 +20,23 @@ import { createSitemapMetadata } from '../lib/sproutsite/sitemap.js';
|
|
|
20
20
|
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
|
+
import { createStylesPlugin } from './styles.js';
|
|
24
|
+
import {
|
|
25
|
+
resolveComponentAliases,
|
|
26
|
+
type ComponentOverrides,
|
|
27
|
+
} from './component-overrides.js';
|
|
28
|
+
|
|
29
|
+
export interface SproutsiteConfigOptions {
|
|
30
|
+
/** Project-relative CSS files, loaded after the default theme in list order. */
|
|
31
|
+
styles?: readonly string[];
|
|
32
|
+
/** Optional website-owned Header/Footer Astro components. */
|
|
33
|
+
components?: ComponentOverrides;
|
|
34
|
+
}
|
|
23
35
|
|
|
24
36
|
/** Returns the Astro configuration required by the default Sproutsite theme. */
|
|
25
|
-
export function createSproutsiteConfig() {
|
|
37
|
+
export function createSproutsiteConfig(options: SproutsiteConfigOptions = {}) {
|
|
38
|
+
const stylesPlugin = createStylesPlugin(options.styles);
|
|
39
|
+
const componentAliases = resolveComponentAliases(options.components);
|
|
26
40
|
validateSproutsiteContent();
|
|
27
41
|
const site = loadSiteConfig();
|
|
28
42
|
for (const locale of site.i18n.locales) {
|
|
@@ -161,7 +175,10 @@ export function createSproutsiteConfig() {
|
|
|
161
175
|
},
|
|
162
176
|
} satisfies AstroIntegration,
|
|
163
177
|
],
|
|
164
|
-
vite: {
|
|
178
|
+
vite: {
|
|
179
|
+
plugins: [stylesPlugin, tailwindcss()],
|
|
180
|
+
resolve: { alias: componentAliases },
|
|
181
|
+
},
|
|
165
182
|
markdown: {
|
|
166
183
|
// A high-contrast Shiki theme keeps code comments readable in the
|
|
167
184
|
// documentation as well as in regular content.
|
package/src/package/index.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export { createSproutsiteCollections } from './content.js';
|
|
2
2
|
export { createSproutsiteConfig } from './config.js';
|
|
3
|
-
export type {
|
|
3
|
+
export type { SproutsiteConfigOptions } from './config.js';
|
|
4
|
+
export type {
|
|
5
|
+
Link,
|
|
6
|
+
SiteConfig,
|
|
7
|
+
Tone,
|
|
8
|
+
HeaderProps,
|
|
9
|
+
FooterProps,
|
|
10
|
+
} from '../lib/sproutsite/types.js';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
2
|
+
import { extname, isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const entry = fileURLToPath(
|
|
6
|
+
new URL('./styles.css', import.meta.url),
|
|
7
|
+
).replaceAll('\\', '/');
|
|
8
|
+
|
|
9
|
+
/** One CSS entry keeps the theme and site overrides in the same import graph.
|
|
10
|
+
* Astro/Vite still handle CSS compilation, assets, watching and output files.
|
|
11
|
+
*/
|
|
12
|
+
export function createStylesPlugin(
|
|
13
|
+
styles: readonly string[] = [],
|
|
14
|
+
root = process.cwd(),
|
|
15
|
+
) {
|
|
16
|
+
if (!Array.isArray(styles))
|
|
17
|
+
throw new Error(
|
|
18
|
+
'Sproutsite styles must be an array of local CSS file paths.',
|
|
19
|
+
);
|
|
20
|
+
const paths = styles.map((path, index) => {
|
|
21
|
+
if (
|
|
22
|
+
typeof path !== 'string' ||
|
|
23
|
+
path.trim() === '' ||
|
|
24
|
+
isAbsolute(path) ||
|
|
25
|
+
/^[a-z][a-z\d+.-]*:/i.test(path) ||
|
|
26
|
+
/[?#\0\r\n]/.test(path) ||
|
|
27
|
+
extname(path).toLowerCase() !== '.css'
|
|
28
|
+
) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Invalid Sproutsite styles[${index}]: expected a project-relative .css file, for example ./src/styles/custom.css.`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const absolute = resolve(root, path);
|
|
34
|
+
try {
|
|
35
|
+
if (!statSync(absolute).isFile())
|
|
36
|
+
throw new Error('not a regular file');
|
|
37
|
+
} catch {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Invalid Sproutsite styles[${index}]: CSS file does not exist or is not a regular file: ${path}`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return absolute;
|
|
43
|
+
});
|
|
44
|
+
// JSON string quoting also handles spaces and quotes in CSS import paths.
|
|
45
|
+
const css = paths
|
|
46
|
+
.map((path) => `@import ${JSON.stringify(path.replaceAll('\\', '/'))};`)
|
|
47
|
+
.join('\n');
|
|
48
|
+
return {
|
|
49
|
+
name: 'sproutsite/theme-styles',
|
|
50
|
+
enforce: 'pre' as const,
|
|
51
|
+
transform(code: string, id: string) {
|
|
52
|
+
if (
|
|
53
|
+
id.split('?')[0]?.replaceAll('\\', '/') !== entry ||
|
|
54
|
+
paths.length === 0
|
|
55
|
+
)
|
|
56
|
+
return;
|
|
57
|
+
return code + '\n' + css;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -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 {
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
import '
|
|
3
|
-
import Header from '
|
|
2
|
+
import '../../../../package/styles.css';
|
|
3
|
+
import Header from '#sproutsite/header';
|
|
4
4
|
import { t } from '../../i18n/index.js';
|
|
5
|
-
import Footer from '
|
|
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';
|