@documental-xyz/core 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/README.md +424 -0
- package/integration.ts +113 -0
- package/package.json +83 -0
- package/src/admin/admin.astro +29 -0
- package/src/assets/scripts/App.js +70 -0
- package/src/assets/scripts/EnteringAnimations.js +34 -0
- package/src/assets/scripts/MapBoxHandler.js +680 -0
- package/src/assets/scripts/ScrollProgressionBar.js +24 -0
- package/src/assets/scripts/utils/ScrollObserver.js +166 -0
- package/src/assets/styles/config/_breakpoints.scss +37 -0
- package/src/assets/styles/config/_colors.scss +8 -0
- package/src/assets/styles/config/_config.scss +5 -0
- package/src/assets/styles/config/_functions.scss +90 -0
- package/src/assets/styles/config/_grrr.configs.scss +7 -0
- package/src/assets/styles/config/_mixins.scss +207 -0
- package/src/assets/styles/config/_type.scss +175 -0
- package/src/assets/styles/config/_vars.scss +16 -0
- package/src/assets/styles/globals/_content.scss +47 -0
- package/src/assets/styles/globals/_grrr.scss +18 -0
- package/src/assets/styles/globals/_html.scss +25 -0
- package/src/assets/styles/globals/_lists.scss +19 -0
- package/src/assets/styles/globals/_map-anchors.scss +32 -0
- package/src/assets/styles/globals/_reset.scss +240 -0
- package/src/assets/styles/globals/_reveal-animations.scss +104 -0
- package/src/assets/styles/globals/_root.scss +6 -0
- package/src/assets/styles/globals/_scroll-progression-bar.scss +8 -0
- package/src/assets/styles/main.scss +17 -0
- package/src/assets/styles/utils/.gitkeep +0 -0
- package/src/assets/styles/utils/grrr/_grrr.scss +433 -0
- package/src/assets/styles/utils/list-styles/_list-styles.scss +190 -0
- package/src/components/AnimationToggle.astro +19 -0
- package/src/components/BigNumbers.astro +83 -0
- package/src/components/Button.astro +49 -0
- package/src/components/Caption.astro +15 -0
- package/src/components/Card.astro +68 -0
- package/src/components/Cards.astro +66 -0
- package/src/components/CardsCall.astro +125 -0
- package/src/components/ChartBar.astro +217 -0
- package/src/components/ChartPercentage.astro +137 -0
- package/src/components/Column.astro +54 -0
- package/src/components/ColumnSticky.astro +129 -0
- package/src/components/Columns.astro +139 -0
- package/src/components/Compare.astro +266 -0
- package/src/components/Cta.astro +242 -0
- package/src/components/Gallery.astro +594 -0
- package/src/components/Group.astro +140 -0
- package/src/components/HtmlEmbed.astro +98 -0
- package/src/components/ImageBlock.astro +134 -0
- package/src/components/InnerColumns.astro +54 -0
- package/src/components/LogosGroup.astro +102 -0
- package/src/components/Map.astro +321 -0
- package/src/components/MapBox.astro +96 -0
- package/src/components/MapView.astro +30 -0
- package/src/components/Menu.astro +278 -0
- package/src/components/Pullquote.astro +46 -0
- package/src/components/Slider.astro +223 -0
- package/src/components/Spacer.astro +25 -0
- package/src/components/Text.astro +173 -0
- package/src/components/TextPlaceholder.astro +98 -0
- package/src/components/Timeline.astro +73 -0
- package/src/components/TimelineBullet.astro +67 -0
- package/src/components/VideoEmbed.astro +99 -0
- package/src/content/loader.ts +29 -0
- package/src/content/pages/alter-ameacada.md +80 -0
- package/src/content/pages/expulsions.md +1447 -0
- package/src/content/pages/home.md +346 -0
- package/src/content/pages/nhanderekoa-studio-autonoma.md +3113 -0
- package/src/content/pages/nhanderekoa-terra-ind/303/255gena-jaragu/303/241.md +3806 -0
- package/src/content/pages/nova-landing-page.md +546 -0
- package/src/content/pages/territ/303/263rios-de-exce/303/247/303/243o.md +2199 -0
- package/src/content/pages/teste-alter-do-chao.md +955 -0
- package/src/content/pages/teste-layout.md +1484 -0
- package/src/content/pages/thiago.md +93 -0
- package/src/content/schema/blog.ts +11 -0
- package/src/content/schema/geostorys.ts +13 -0
- package/src/content/schema/index.ts +3 -0
- package/src/content/schema/pages.ts +494 -0
- package/src/content.config.ts +49 -0
- package/src/env.d.ts +1 -0
- package/src/integration/override-aliases.ts +67 -0
- package/src/layouts/components/ButtonLayout.astro +8 -0
- package/src/layouts/components/CardLayout.astro +8 -0
- package/src/layouts/components/CardsCallLayout.astro +26 -0
- package/src/layouts/components/CardsLayout.astro +14 -0
- package/src/layouts/components/ChartBarLayout.astro +21 -0
- package/src/layouts/components/ChartPercentageLayout.astro +17 -0
- package/src/layouts/components/ColumnLayout.astro +11 -0
- package/src/layouts/components/ColumnStickyLayout.astro +10 -0
- package/src/layouts/components/ColumnsLayout.astro +13 -0
- package/src/layouts/components/CompareLayout.astro +22 -0
- package/src/layouts/components/CtaLayout.astro +91 -0
- package/src/layouts/components/GalleryLayout.astro +24 -0
- package/src/layouts/components/GroupLayout.astro +53 -0
- package/src/layouts/components/HtmlEmbedLayout.astro +18 -0
- package/src/layouts/components/ImageBlockLayout.astro +20 -0
- package/src/layouts/components/InnerColumnsLayout.astro +14 -0
- package/src/layouts/components/LogosGroupLayout.astro +22 -0
- package/src/layouts/components/MapLayout.astro +41 -0
- package/src/layouts/components/MapViewLayout.astro +8 -0
- package/src/layouts/components/MapboxLayout.astro +248 -0
- package/src/layouts/components/PullquoteLayout.astro +13 -0
- package/src/layouts/components/SliderLayout.astro +18 -0
- package/src/layouts/components/SpacerLayout.astro +8 -0
- package/src/layouts/components/TextLayout.astro +17 -0
- package/src/layouts/components/TextPlaceholderLayout.astro +7 -0
- package/src/layouts/components/TimelineBulletLayout.astro +14 -0
- package/src/layouts/components/TimelineLayout.astro +10 -0
- package/src/layouts/components/VideoEmbedLayout.astro +28 -0
- package/src/layouts/pages/Layout.astro +90 -0
- package/src/layouts/pages/PageLayout.astro +200 -0
- package/src/lib/collections.ts +1 -0
- package/src/routes/[slug].astro +17 -0
- package/src/routes/index.astro +5 -0
- package/src/vite/yaml-merge-plugin.ts +234 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin: merges Sveltia CMS YAML config fragments into a single
|
|
3
|
+
* `public/admin/config.yml`, substituting placeholders from integration
|
|
4
|
+
* options.
|
|
5
|
+
*
|
|
6
|
+
* ## Why text-concatenation, not parse-then-merge?
|
|
7
|
+
*
|
|
8
|
+
* The YAML fragments in `public/admin/config/components/*.yml` define anchors
|
|
9
|
+
* (e.g. `&pageSettings`) that are aliased (`*pageSettings`) by the collections
|
|
10
|
+
* fragments in `public/admin/config/collections/*.yml`. Anchors only resolve
|
|
11
|
+
* within a single YAML document. The predecessor `vite.config.mjs` plugin had
|
|
12
|
+
* a bug: it parsed each file independently (`mergedConfig = { ...mergedConfig,
|
|
13
|
+
* ...parsed }`), which (a) shallow-merged and (b) dropped all cross-file
|
|
14
|
+
* anchor resolution.
|
|
15
|
+
*
|
|
16
|
+
* The correct approach — inherited from the now-deleted `build-config.js` —
|
|
17
|
+
* is to concatenate the fragment texts in order into one YAML stream, then
|
|
18
|
+
* let `js-yaml` resolve anchors across the whole stream in a single pass.
|
|
19
|
+
* Because each fragment contributes distinct top-level keys, the resulting
|
|
20
|
+
* document is the deep union of all fragments. Placeholders are substituted
|
|
21
|
+
* on the final concatenated text before parse.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { glob } from 'glob';
|
|
27
|
+
import fs from 'node:fs';
|
|
28
|
+
import path from 'node:path';
|
|
29
|
+
import { fileURLToPath } from 'node:url';
|
|
30
|
+
import yaml from 'js-yaml';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Root of the @documental-xyz/core package, resolved from this module's
|
|
34
|
+
* location. Template YAML files (main.yml.template, components/, collections/)
|
|
35
|
+
* live under `public/admin/config/` relative to this root. The output
|
|
36
|
+
* `config.yml` is written to the consumer's `public/admin/`.
|
|
37
|
+
*/
|
|
38
|
+
const CORE_ROOT = path.resolve(
|
|
39
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
40
|
+
'../..'
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/** Options for {@link createYamlMergePlugin}. */
|
|
44
|
+
export interface YamlMergePluginOptions {
|
|
45
|
+
/** GitHub repo in `owner/name` form. Required. Substitutes `${REPO}`. */
|
|
46
|
+
repo: string;
|
|
47
|
+
/** Git branch. Defaults to `'main'`. Substitutes `${BRANCH}`. */
|
|
48
|
+
branch?: string;
|
|
49
|
+
/** Auth base URL for Sveltia auth. Substitutes `${AUTH_BASE_URL}`. */
|
|
50
|
+
authBaseUrl?: string;
|
|
51
|
+
/** CMS media_folder. Defaults to `'public/uploads'`. Substitutes `${MEDIA_FOLDER}`. */
|
|
52
|
+
mediaFolder?: string;
|
|
53
|
+
/** CMS public_folder. Defaults to `'uploads'`. Substitutes `${PUBLIC_FOLDER}`. */
|
|
54
|
+
publicFolder?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Override the core package root for template resolution.
|
|
57
|
+
* Defaults to `CORE_ROOT` (resolved from this module's location).
|
|
58
|
+
* Only needed in tests or unusual consumption scenarios.
|
|
59
|
+
*/
|
|
60
|
+
coreRoot?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Resolved options after defaults applied. */
|
|
64
|
+
interface ResolvedOptions {
|
|
65
|
+
repo: string;
|
|
66
|
+
branch: string;
|
|
67
|
+
authBaseUrl: string;
|
|
68
|
+
mediaFolder: string;
|
|
69
|
+
publicFolder: string;
|
|
70
|
+
coreRoot: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Default option values — kept here so tests can reference them too. */
|
|
74
|
+
export const YAML_MERGE_DEFAULTS = {
|
|
75
|
+
branch: 'main',
|
|
76
|
+
mediaFolder: 'public/uploads',
|
|
77
|
+
publicFolder: 'uploads',
|
|
78
|
+
} as const;
|
|
79
|
+
|
|
80
|
+
function resolveOptions(opts: YamlMergePluginOptions): ResolvedOptions {
|
|
81
|
+
if (!opts || typeof opts.repo !== 'string' || opts.repo.length === 0) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
'[documental-yaml-merge] option `repo` is required (e.g. "owner/name").'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
repo: opts.repo,
|
|
88
|
+
branch: opts.branch ?? YAML_MERGE_DEFAULTS.branch,
|
|
89
|
+
authBaseUrl: opts.authBaseUrl ?? '',
|
|
90
|
+
mediaFolder: opts.mediaFolder ?? YAML_MERGE_DEFAULTS.mediaFolder,
|
|
91
|
+
publicFolder: opts.publicFolder ?? YAML_MERGE_DEFAULTS.publicFolder,
|
|
92
|
+
coreRoot: opts.coreRoot ?? CORE_ROOT,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Substitute `${PLACEHOLDER}` tokens in `text` using `values`.
|
|
98
|
+
* Unknown placeholders are left untouched (they may be intended for a later
|
|
99
|
+
* substitution pass, e.g. user-authored content).
|
|
100
|
+
*/
|
|
101
|
+
export function substitutePlaceholders(
|
|
102
|
+
text: string,
|
|
103
|
+
values: Record<string, string>
|
|
104
|
+
): string {
|
|
105
|
+
return text.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/g, (match, name) =>
|
|
106
|
+
Object.prototype.hasOwnProperty.call(values, name) ? values[name] : match
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Read a file, returning empty string if it does not exist. */
|
|
111
|
+
function readIfExists(p: string): string | null {
|
|
112
|
+
try {
|
|
113
|
+
return fs.readFileSync(p, 'utf8');
|
|
114
|
+
} catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Build the merged YAML text by concatenating fragments in the canonical
|
|
121
|
+
* order: main (template preferred) → components (per `components.yml`) →
|
|
122
|
+
* collections (alphabetical).
|
|
123
|
+
*
|
|
124
|
+
* Exposed for testability.
|
|
125
|
+
*/
|
|
126
|
+
export async function buildMergedYamlText(
|
|
127
|
+
projectRoot: string,
|
|
128
|
+
resolved: ResolvedOptions
|
|
129
|
+
): Promise<string> {
|
|
130
|
+
const adminDir = path.join(resolved.coreRoot, 'public/admin');
|
|
131
|
+
const configDir = path.join(adminDir, 'config');
|
|
132
|
+
|
|
133
|
+
// 1. Main config — prefer T7's template, fall back to static main.yml.
|
|
134
|
+
const templatePath = path.join(configDir, 'main.yml.template');
|
|
135
|
+
const mainPath = path.join(configDir, 'main.yml');
|
|
136
|
+
const mainRaw =
|
|
137
|
+
readIfExists(templatePath) ?? readIfExists(mainPath) ?? '';
|
|
138
|
+
if (mainRaw === '') {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`[documental-yaml-merge] no main config found: expected ${templatePath} or ${mainPath}.`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 2. Components in the order declared by components.yml.
|
|
145
|
+
const componentsManifestPath = path.join(adminDir, 'components.yml');
|
|
146
|
+
const componentsManifestRaw = readIfExists(componentsManifestPath);
|
|
147
|
+
let componentOrder: string[] = [];
|
|
148
|
+
if (componentsManifestRaw) {
|
|
149
|
+
const manifest = yaml.load(componentsManifestRaw) as {
|
|
150
|
+
components?: string[];
|
|
151
|
+
};
|
|
152
|
+
componentOrder = Array.isArray(manifest?.components)
|
|
153
|
+
? (manifest!.components as string[])
|
|
154
|
+
: [];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 3. Collections (alphabetical — matches original build-config.js behavior).
|
|
158
|
+
const collectionFiles = await glob(
|
|
159
|
+
path.join(configDir, 'collections/*.yml').replace(/\\/g, '/')
|
|
160
|
+
);
|
|
161
|
+
collectionFiles.sort();
|
|
162
|
+
|
|
163
|
+
// Concatenate everything into one YAML stream. Trailing newline separators
|
|
164
|
+
// keep top-level keys from adjacent fragments on distinct document lines.
|
|
165
|
+
const parts: string[] = [];
|
|
166
|
+
parts.push(mainRaw.replace(/\s+$/, ''));
|
|
167
|
+
for (const rel of componentOrder) {
|
|
168
|
+
const full = path.join(configDir, rel);
|
|
169
|
+
const content = readIfExists(full);
|
|
170
|
+
if (content === null) {
|
|
171
|
+
console.warn(
|
|
172
|
+
`[documental-yaml-merge] component file listed in components.yml not found: ${rel}`
|
|
173
|
+
);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
parts.push(content.replace(/\s+$/, ''));
|
|
177
|
+
}
|
|
178
|
+
for (const file of collectionFiles) {
|
|
179
|
+
const content = readIfExists(file);
|
|
180
|
+
if (content === null) continue;
|
|
181
|
+
parts.push(content.replace(/\s+$/, ''));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const concatenated = parts.join('\n') + '\n';
|
|
185
|
+
|
|
186
|
+
// Substitute placeholders on the merged text. Substituting AFTER concat
|
|
187
|
+
// (rather than only on main.yml) keeps the door open to placeholders in any
|
|
188
|
+
// fragment — harmless when none are present.
|
|
189
|
+
return substitutePlaceholders(concatenated, {
|
|
190
|
+
REPO: resolved.repo,
|
|
191
|
+
BRANCH: resolved.branch,
|
|
192
|
+
AUTH_BASE_URL: resolved.authBaseUrl,
|
|
193
|
+
MEDIA_FOLDER: resolved.mediaFolder,
|
|
194
|
+
PUBLIC_FOLDER: resolved.publicFolder,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Create a Vite plugin that merges Sveltia CMS YAML fragments into
|
|
200
|
+
* `public/admin/config.yml` at build-start. Runs in BOTH `dev` and `build`.
|
|
201
|
+
*/
|
|
202
|
+
export function createYamlMergePlugin(options: YamlMergePluginOptions): {
|
|
203
|
+
name: string;
|
|
204
|
+
buildStart: () => Promise<void>;
|
|
205
|
+
} {
|
|
206
|
+
const resolved = resolveOptions(options);
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
name: 'documental-yaml-merge',
|
|
210
|
+
async buildStart() {
|
|
211
|
+
const projectRoot = process.cwd();
|
|
212
|
+
const mergedText = await buildMergedYamlText(projectRoot, resolved);
|
|
213
|
+
|
|
214
|
+
// Sanity: the merged stream must parse cleanly (catches broken anchors).
|
|
215
|
+
// We discard the parsed value — the artifact is the text itself, to
|
|
216
|
+
// preserve comments, anchor definitions, and original formatting.
|
|
217
|
+
try {
|
|
218
|
+
yaml.load(mergedText, { schema: yaml.DEFAULT_FULL_SCHEMA });
|
|
219
|
+
} catch (err) {
|
|
220
|
+
throw new Error(
|
|
221
|
+
`[documental-yaml-merge] merged config failed to parse: ${(err as Error).message}`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const outDir = path.join(projectRoot, 'public/admin');
|
|
226
|
+
if (!fs.existsSync(outDir)) {
|
|
227
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
228
|
+
}
|
|
229
|
+
fs.writeFileSync(path.join(outDir, 'config.yml'), mergedText);
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export default createYamlMergePlugin;
|