sproutsite 0.0.0-stage → 0.5.7

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.
Files changed (116) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +14 -0
  3. package/README.md +604 -2
  4. package/THIRD_PARTY_NOTICES.md +85 -0
  5. package/VERSION +1 -0
  6. package/package.json +107 -5
  7. package/src/lib/sproutsite/colors.ts +7 -0
  8. package/src/lib/sproutsite/language-links.ts +60 -0
  9. package/src/lib/sproutsite/pages.ts +78 -0
  10. package/src/lib/sproutsite/rehype-ids.ts +20 -0
  11. package/src/lib/sproutsite/rehype-links.ts +19 -0
  12. package/src/lib/sproutsite/rehype-tables.ts +74 -0
  13. package/src/lib/sproutsite/remark-links.ts +19 -0
  14. package/src/lib/sproutsite/site-config.ts +110 -0
  15. package/src/lib/sproutsite/sitemap.ts +160 -0
  16. package/src/lib/sproutsite/types.ts +45 -0
  17. package/src/lib/sproutsite/urls.ts +79 -0
  18. package/src/lib/sproutsite/validation.ts +1406 -0
  19. package/src/package/404.astro +5 -0
  20. package/src/package/500.astro +5 -0
  21. package/src/package/components.ts +17 -0
  22. package/src/package/config.ts +161 -0
  23. package/src/package/content.ts +117 -0
  24. package/src/package/index.ts +3 -0
  25. package/src/package/manifest.ts +27 -0
  26. package/src/package/page.astro +124 -0
  27. package/src/themes/default/assets/branding/apple-touch-icon.png +0 -0
  28. package/src/themes/default/assets/branding/favicon-16x16.png +0 -0
  29. package/src/themes/default/assets/branding/favicon-32x32.png +0 -0
  30. package/src/themes/default/assets/branding/favicon-48x48.png +0 -0
  31. package/src/themes/default/assets/branding/favicon.ico +0 -0
  32. package/src/themes/default/assets/branding/favicon.svg +1 -0
  33. package/src/themes/default/assets/branding/icon-192x192.png +0 -0
  34. package/src/themes/default/assets/branding/icon-512x512.png +0 -0
  35. package/src/themes/default/assets/branding/icon-monochrome.svg +1 -0
  36. package/src/themes/default/assets/branding/icon.svg +18 -0
  37. package/src/themes/default/assets/branding/logo-dark.svg +18 -0
  38. package/src/themes/default/assets/branding/logo-monochrome.svg +1 -0
  39. package/src/themes/default/assets/branding/logo.svg +18 -0
  40. package/src/themes/default/assets/branding/social-card.png +0 -0
  41. package/src/themes/default/assets/hero-waves.svg +41 -0
  42. package/src/themes/default/components/atoms/Badge/Badge.astro +65 -0
  43. package/src/themes/default/components/atoms/Badge/Badge.css +5 -0
  44. package/src/themes/default/components/atoms/BrandLogo/BrandLogo.astro +26 -0
  45. package/src/themes/default/components/atoms/BrandLogo/BrandLogo.css +22 -0
  46. package/src/themes/default/components/atoms/Button/Button.astro +106 -0
  47. package/src/themes/default/components/atoms/Button/Button.css +14 -0
  48. package/src/themes/default/components/atoms/ContentImage/ContentImage.astro +54 -0
  49. package/src/themes/default/components/atoms/ContentImage/ContentImage.css +21 -0
  50. package/src/themes/default/components/atoms/Eyebrow/Eyebrow.astro +3 -0
  51. package/src/themes/default/components/atoms/Eyebrow/Eyebrow.css +18 -0
  52. package/src/themes/default/components/atoms/Icon/Icon.astro +80 -0
  53. package/src/themes/default/components/atoms/Icon/Icon.css +68 -0
  54. package/src/themes/default/components/atoms/Tab/Tab.astro +15 -0
  55. package/src/themes/default/components/atoms/Tab/Tab.css +34 -0
  56. package/src/themes/default/components/layout/Column/Column.astro +18 -0
  57. package/src/themes/default/components/layout/Column/Column.css +82 -0
  58. package/src/themes/default/components/layout/Columns/Columns.astro +163 -0
  59. package/src/themes/default/components/layout/Columns/Columns.css +177 -0
  60. package/src/themes/default/components/molecules/Accordion/Accordion.astro +17 -0
  61. package/src/themes/default/components/molecules/Accordion/Accordion.css +11 -0
  62. package/src/themes/default/components/molecules/Accordion/accordion.ts +47 -0
  63. package/src/themes/default/components/molecules/AccordionItem/AccordionItem.astro +100 -0
  64. package/src/themes/default/components/molecules/AccordionItem/AccordionItem.css +118 -0
  65. package/src/themes/default/components/molecules/Alert/Alert.astro +42 -0
  66. package/src/themes/default/components/molecules/Alert/Alert.css +13 -0
  67. package/src/themes/default/components/molecules/Card/Card.astro +57 -0
  68. package/src/themes/default/components/molecules/Card/Card.css +25 -0
  69. package/src/themes/default/components/molecules/CardActions/CardActions.astro +3 -0
  70. package/src/themes/default/components/molecules/CardActions/CardActions.css +13 -0
  71. package/src/themes/default/components/molecules/ContentTable/ContentTable.astro +42 -0
  72. package/src/themes/default/components/molecules/ContentTable/ContentTable.css +59 -0
  73. package/src/themes/default/components/molecules/Feature/Feature.astro +108 -0
  74. package/src/themes/default/components/molecules/Feature/Feature.css +157 -0
  75. package/src/themes/default/components/molecules/FoundationSample/FoundationSample.astro +165 -0
  76. package/src/themes/default/components/molecules/FoundationSample/FoundationSample.css +201 -0
  77. package/src/themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.astro +118 -0
  78. package/src/themes/default/components/molecules/LanguageSwitcher/LanguageSwitcher.css +134 -0
  79. package/src/themes/default/components/molecules/Tabs/Tabs.astro +33 -0
  80. package/src/themes/default/components/molecules/Tabs/Tabs.css +38 -0
  81. package/src/themes/default/components/molecules/Tabs/tabs.ts +91 -0
  82. package/src/themes/default/components/organisms/BlogIndex/BlogIndex.astro +86 -0
  83. package/src/themes/default/components/organisms/BlogIndex/BlogIndex.css +17 -0
  84. package/src/themes/default/components/organisms/BlogPost/BlogPost.astro +51 -0
  85. package/src/themes/default/components/organisms/BlogPost/BlogPost.css +5 -0
  86. package/src/themes/default/components/organisms/Footer/Footer.astro +57 -0
  87. package/src/themes/default/components/organisms/Footer/Footer.css +63 -0
  88. package/src/themes/default/components/organisms/Header/Header.astro +223 -0
  89. package/src/themes/default/components/organisms/Header/Header.css +282 -0
  90. package/src/themes/default/components/organisms/Hero/Hero.astro +106 -0
  91. package/src/themes/default/components/organisms/Hero/Hero.css +187 -0
  92. package/src/themes/default/components/organisms/PageTitle/PageTitle.astro +39 -0
  93. package/src/themes/default/components/organisms/PageTitle/PageTitle.css +25 -0
  94. package/src/themes/default/components/organisms/Section/Section.astro +39 -0
  95. package/src/themes/default/components/organisms/Section/Section.css +21 -0
  96. package/src/themes/default/i18n/de.yaml +38 -0
  97. package/src/themes/default/i18n/en.yaml +38 -0
  98. package/src/themes/default/i18n/index.ts +63 -0
  99. package/src/themes/default/layouts/ErrorPage/ErrorPage.astro +110 -0
  100. package/src/themes/default/layouts/PageLayout/PageLayout.astro +108 -0
  101. package/src/themes/default/layouts/PageLayout/PageLayout.css +15 -0
  102. package/src/themes/default/styles/foundation/base.css +19 -0
  103. package/src/themes/default/styles/foundation/focus.css +6 -0
  104. package/src/themes/default/styles/foundation/fonts/OFL.txt +93 -0
  105. package/src/themes/default/styles/foundation/fonts/nunito-latin-variable.woff2 +0 -0
  106. package/src/themes/default/styles/foundation/fonts.css +17 -0
  107. package/src/themes/default/styles/foundation/layout.css +6 -0
  108. package/src/themes/default/styles/foundation/prose.css +54 -0
  109. package/src/themes/default/styles/foundation/tokens.css +48 -0
  110. package/src/themes/default/styles/theme.css +99 -0
  111. package/src/themes/default/styles/themes/section-tones.css +30 -0
  112. package/third-party-licenses/daisyui-LICENSE +21 -0
  113. package/third-party-licenses/flag-icons-LICENSE +21 -0
  114. package/third-party-licenses/lucide-LICENSE +43 -0
  115. package/third-party-licenses/tailwindcss-LICENSE +21 -0
  116. package/third-party-licenses/tailwindcss-typography-LICENSE +21 -0
@@ -0,0 +1,160 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
3
+ import { dirname, join, relative, resolve } from 'node:path';
4
+ import { parse } from 'yaml';
5
+ import type { SitemapItem } from '@astrojs/sitemap';
6
+ import { assemblePages } from './pages.js';
7
+ import { localeOf, logicalId } from './language-links.js';
8
+ import { blogRouteFromId, canonicalUrl } from './urls.js';
9
+ import { loadSiteConfig } from './site-config.js';
10
+
11
+ interface MetadataEntry {
12
+ id: string;
13
+ file: string;
14
+ data: { url?: string };
15
+ }
16
+
17
+ function metadataFiles(directory: string): MetadataEntry[] {
18
+ if (!existsSync(directory)) return [];
19
+ return readdirSync(directory, { recursive: true })
20
+ .filter(
21
+ (file): file is string =>
22
+ typeof file === 'string' &&
23
+ /(?:^|\/)page(?:\.de)?\.yaml$/.test(file),
24
+ )
25
+ .map((file) => ({
26
+ id: file.replace(/\.yaml$/, ''),
27
+ file: join(directory, file),
28
+ data: parse(readFileSync(join(directory, file), 'utf8')) as {
29
+ url?: string;
30
+ },
31
+ }));
32
+ }
33
+
34
+ /** Node-compatible metadata for the official sitemap serializer; no Astro runtime APIs. */
35
+ export function createSitemapMetadata(root = process.cwd()) {
36
+ const site = loadSiteConfig(undefined, root);
37
+ const pages = metadataFiles(join(root, 'src/content/pages'));
38
+ const posts = metadataFiles(join(root, 'src/content/blog'));
39
+ const entries: {
40
+ key: string;
41
+ locale: string;
42
+ url: string;
43
+ files: string[];
44
+ directory?: string;
45
+ }[] = [];
46
+ for (const locale of site.locales) {
47
+ const localizedSite = loadSiteConfig(locale, root);
48
+ const siteFiles = [
49
+ join(root, 'src/content/site.yaml'),
50
+ join(root, `src/content/site.${locale}.yaml`),
51
+ ].filter(existsSync);
52
+ const filesFor = (entry: MetadataEntry) => [
53
+ ...siteFiles,
54
+ ...readdirSync(dirname(entry.file))
55
+ .filter(
56
+ (name) =>
57
+ name ===
58
+ (locale === 'en'
59
+ ? 'page.yaml'
60
+ : `page.${locale}.yaml`) ||
61
+ (/\.(md|mdx)$/.test(name) &&
62
+ localeOf(name.replace(/\.(md|mdx)$/, '')) ===
63
+ locale),
64
+ )
65
+ .map((name) => join(dirname(entry.file), name)),
66
+ ];
67
+ for (const page of assemblePages(
68
+ pages.filter((entry) => localeOf(entry.id) === locale),
69
+ [],
70
+ undefined,
71
+ (entry) => logicalId(entry.id),
72
+ )) {
73
+ entries.push({
74
+ key: `page:${logicalId(page.entry.id)}`,
75
+ locale,
76
+ url: canonicalUrl(page.route, localizedSite),
77
+ files: filesFor(page.entry),
78
+ directory: dirname(page.entry.file),
79
+ });
80
+ }
81
+ const localizedPosts = posts.filter(
82
+ (entry) => localeOf(entry.id) === locale,
83
+ );
84
+ for (const post of localizedPosts) {
85
+ const articleId = dirname(post.id);
86
+ entries.push({
87
+ key: `post:${articleId}`,
88
+ locale,
89
+ url: canonicalUrl(blogRouteFromId(articleId), localizedSite),
90
+ files: filesFor(post),
91
+ directory: dirname(post.file),
92
+ });
93
+ }
94
+ entries.push({
95
+ key: 'blog-index',
96
+ locale,
97
+ url: canonicalUrl('/blog/', localizedSite),
98
+ files: [...siteFiles, ...localizedPosts.map((post) => post.file)],
99
+ });
100
+ }
101
+
102
+ const git = (args: string[]) => {
103
+ try {
104
+ return execFileSync('git', args, {
105
+ cwd: root,
106
+ encoding: 'utf8',
107
+ stdio: ['ignore', 'pipe', 'ignore'],
108
+ });
109
+ } catch {
110
+ return '';
111
+ }
112
+ };
113
+ const changed = git([
114
+ 'status',
115
+ '--porcelain=v1',
116
+ '-z',
117
+ '--untracked-files=all',
118
+ ])
119
+ .split('\0')
120
+ .filter((line) => line.length > 3)
121
+ .map((line) => resolve(root, line.slice(3)));
122
+ const modified = (files: string[], directory?: string) => {
123
+ // Include deleted direct content files in the history query as well.
124
+ const paths = files.map((file) => relative(root, file));
125
+ if (directory) paths.push(`:(glob)${relative(root, directory)}/*`);
126
+ const committed = git([
127
+ 'log',
128
+ '-1',
129
+ '--format=%cI',
130
+ '--',
131
+ ...paths,
132
+ ]).trim();
133
+ const times = committed ? [Date.parse(committed)] : [];
134
+ for (const file of files) {
135
+ if (!committed || changed.includes(resolve(file)))
136
+ times.push(statSync(file).mtimeMs);
137
+ }
138
+ return new Date(Math.max(...times)).toISOString();
139
+ };
140
+ const metadata = new Map<string, Pick<SitemapItem, 'lastmod' | 'links'>>();
141
+ for (const entry of entries) {
142
+ const equivalents = entries.filter(
143
+ (candidate) => candidate.key === entry.key,
144
+ );
145
+ const links = equivalents.map((candidate) => ({
146
+ lang: candidate.locale,
147
+ url: candidate.url,
148
+ }));
149
+ const defaultEntry = equivalents.find(
150
+ (candidate) => candidate.locale === site.language,
151
+ );
152
+ if (defaultEntry)
153
+ links.push({ lang: 'x-default', url: defaultEntry.url });
154
+ metadata.set(entry.url, {
155
+ links,
156
+ lastmod: modified(entry.files, entry.directory),
157
+ });
158
+ }
159
+ return metadata;
160
+ }
@@ -0,0 +1,45 @@
1
+ export const tones = ['default', 'muted', 'brand'] as const;
2
+ export type Tone = (typeof tones)[number];
3
+ export type SectionTone = Tone | { odd: Tone; even: Tone };
4
+ export const heroTypes = ['small', 'big', 'fullscreen'] as const;
5
+ export const sectionSpacings = ['small', 'default', 'large'] as const;
6
+
7
+ export interface Link {
8
+ label: string;
9
+ href: string;
10
+ }
11
+
12
+ export type HeaderItem =
13
+ | (Link & { type?: 'link'; icon?: string })
14
+ | (Link & {
15
+ type: 'cta';
16
+ icon?: string;
17
+ variant?:
18
+ | 'primary'
19
+ | 'secondary'
20
+ | 'accent'
21
+ | 'neutral'
22
+ | 'info'
23
+ | 'success'
24
+ | 'warning'
25
+ | 'error';
26
+ })
27
+ | { type: 'separator' }
28
+ | { type: 'language-switcher' };
29
+
30
+ export interface SiteConfig {
31
+ name: string;
32
+ url: string;
33
+ base: string;
34
+ language: string;
35
+ locales: string[];
36
+ heroClasses: string[];
37
+ blog?: {
38
+ title: string;
39
+ description: string;
40
+ eyebrow: string;
41
+ heading: string;
42
+ };
43
+ header: { links: HeaderItem[] };
44
+ footer: { text: string; links: Link[] };
45
+ }
@@ -0,0 +1,79 @@
1
+ import type { SiteConfig } from './types.js';
2
+
3
+ export function pageDirectoryFromId(id: string): string {
4
+ const directory = id
5
+ .replace(/(?:^|\/)page(?:\.ya?ml)?$/, '')
6
+ .replace(/^\/+|\/+$/g, '');
7
+ if (
8
+ directory !== '' &&
9
+ directory
10
+ .split('/')
11
+ .some((part) => part === '.' || part === '..' || part === '')
12
+ ) {
13
+ throw new Error(`Unsafe page identifier: ${id}`);
14
+ }
15
+ return directory;
16
+ }
17
+
18
+ export function routeFromPageId(
19
+ id: string,
20
+ urlSegmentForDirectory?: (directory: string) => string | undefined,
21
+ ): string {
22
+ const directory = pageDirectoryFromId(id);
23
+ if (directory === '') return '/';
24
+ const segments = directory
25
+ .split('/')
26
+ .map(
27
+ (segment, index, allSegments) =>
28
+ urlSegmentForDirectory?.(
29
+ allSegments.slice(0, index + 1).join('/'),
30
+ ) ?? segment,
31
+ );
32
+ return `/${segments.join('/')}/`;
33
+ }
34
+
35
+ export function withBase(pathname: string, base: string): string {
36
+ if (!pathname.startsWith('/') || pathname.startsWith('//')) return pathname;
37
+ const suffix = pathname === '/' ? '' : pathname.slice(1);
38
+ return `${base}${suffix}`;
39
+ }
40
+
41
+ export function contentHref(href: string, site: SiteConfig): string {
42
+ if (!href.startsWith('/') || href.startsWith('//')) return href;
43
+ const defaultLocale = site.locales[0];
44
+ const localePrefix =
45
+ site.language === defaultLocale ? '' : `/${site.language}`;
46
+ const localizedHref =
47
+ localePrefix === '' ||
48
+ href === localePrefix ||
49
+ href.startsWith(`${localePrefix}/`)
50
+ ? href
51
+ : href === '/'
52
+ ? `${localePrefix}/`
53
+ : `${localePrefix}${href}`;
54
+ return withBase(localizedHref, site.base);
55
+ }
56
+
57
+ /** Compare web links with the validated production origin, including in preview builds. */
58
+ export function isExternalWebLink(href: string, siteUrl: string): boolean {
59
+ const site = new URL(siteUrl);
60
+ const target = new URL(href, site);
61
+ return (
62
+ (target.protocol === 'http:' || target.protocol === 'https:') &&
63
+ target.origin !== site.origin
64
+ );
65
+ }
66
+
67
+ export function canonicalUrl(route: string, site: SiteConfig): string {
68
+ return new URL(contentHref(route, site), site.url).toString();
69
+ }
70
+
71
+ /** Derives a safe static route for a dated blog directory identifier. */
72
+ export function blogRouteFromId(id: string): string {
73
+ const normalized = id.replace(/^\/+|\/+$/g, '').replace(/\.de$/, '');
74
+ const match = normalized.match(
75
+ /^\d{4}-\d{2}-\d{2}\.([a-z0-9]+(?:-[a-z0-9]+)*)$/,
76
+ );
77
+ if (!match) throw new Error(`Unsafe blog identifier: ${id}`);
78
+ return `/blog/${match[1]}/`;
79
+ }