@rigel-cms/rigel 1.0.0 → 1.2.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 +8 -0
- package/docs/content-locales.md +53 -0
- package/docs/extensions.md +194 -0
- package/package.json +16 -3
- package/src/article-body.ts +49 -37
- package/src/article-render.ts +25 -2
- package/src/article.ts +44 -0
- package/src/config.ts +26 -2
- package/src/editor/App.svelte +149 -107
- package/src/editor/blocks/extension.ts +29 -0
- package/src/editor/blocks/index.ts +17 -15
- package/src/editor/blocks/video.ts +2 -1
- package/src/editor/i18n/README.md +23 -0
- package/src/editor/i18n/de/connection.json +136 -0
- package/src/editor/i18n/de/defaults.json +6 -0
- package/src/editor/i18n/de/fields.json +130 -0
- package/src/editor/i18n/de/local.json +49 -0
- package/src/editor/i18n/de/media.json +166 -0
- package/src/editor/i18n/de/richtext.json +116 -0
- package/src/editor/i18n/de/shell.json +182 -0
- package/src/editor/i18n/de/system.json +14 -0
- package/src/editor/i18n/de/validation.json +82 -0
- package/src/editor/i18n/en/connection.json +136 -0
- package/src/editor/i18n/en/defaults.json +6 -0
- package/src/editor/i18n/en/fields.json +130 -0
- package/src/editor/i18n/en/local.json +49 -0
- package/src/editor/i18n/en/media.json +166 -0
- package/src/editor/i18n/en/richtext.json +116 -0
- package/src/editor/i18n/en/shell.json +182 -0
- package/src/editor/i18n/en/system.json +14 -0
- package/src/editor/i18n/en/validation.json +82 -0
- package/src/editor/i18n/es/connection.json +136 -0
- package/src/editor/i18n/es/defaults.json +6 -0
- package/src/editor/i18n/es/fields.json +130 -0
- package/src/editor/i18n/es/local.json +49 -0
- package/src/editor/i18n/es/media.json +166 -0
- package/src/editor/i18n/es/richtext.json +116 -0
- package/src/editor/i18n/es/shell.json +182 -0
- package/src/editor/i18n/es/system.json +14 -0
- package/src/editor/i18n/es/validation.json +82 -0
- package/src/editor/i18n/format.ts +26 -0
- package/src/editor/i18n/fr/connection.json +136 -0
- package/src/editor/i18n/fr/defaults.json +6 -0
- package/src/editor/i18n/fr/fields.json +130 -0
- package/src/editor/i18n/fr/local.json +49 -0
- package/src/editor/i18n/fr/media.json +166 -0
- package/src/editor/i18n/fr/richtext.json +116 -0
- package/src/editor/i18n/fr/shell.json +182 -0
- package/src/editor/i18n/fr/system.json +14 -0
- package/src/editor/i18n/fr/validation.json +82 -0
- package/src/editor/i18n/index.ts +18 -0
- package/src/editor/i18n/it/connection.json +136 -0
- package/src/editor/i18n/it/defaults.json +6 -0
- package/src/editor/i18n/it/fields.json +130 -0
- package/src/editor/i18n/it/local.json +49 -0
- package/src/editor/i18n/it/media.json +166 -0
- package/src/editor/i18n/it/richtext.json +116 -0
- package/src/editor/i18n/it/shell.json +182 -0
- package/src/editor/i18n/it/system.json +14 -0
- package/src/editor/i18n/it/validation.json +82 -0
- package/src/editor/i18n/ja/connection.json +136 -0
- package/src/editor/i18n/ja/defaults.json +6 -0
- package/src/editor/i18n/ja/fields.json +130 -0
- package/src/editor/i18n/ja/local.json +49 -0
- package/src/editor/i18n/ja/media.json +166 -0
- package/src/editor/i18n/ja/richtext.json +116 -0
- package/src/editor/i18n/ja/shell.json +182 -0
- package/src/editor/i18n/ja/system.json +14 -0
- package/src/editor/i18n/ja/validation.json +82 -0
- package/src/editor/i18n/locales.ts +13 -0
- package/src/editor/i18n/nl/connection.json +136 -0
- package/src/editor/i18n/nl/defaults.json +6 -0
- package/src/editor/i18n/nl/fields.json +130 -0
- package/src/editor/i18n/nl/local.json +49 -0
- package/src/editor/i18n/nl/media.json +166 -0
- package/src/editor/i18n/nl/richtext.json +116 -0
- package/src/editor/i18n/nl/shell.json +182 -0
- package/src/editor/i18n/nl/system.json +14 -0
- package/src/editor/i18n/nl/validation.json +82 -0
- package/src/editor/i18n/ru/connection.json +138 -0
- package/src/editor/i18n/ru/defaults.json +6 -0
- package/src/editor/i18n/ru/fields.json +132 -0
- package/src/editor/i18n/ru/local.json +49 -0
- package/src/editor/i18n/ru/media.json +166 -0
- package/src/editor/i18n/ru/richtext.json +116 -0
- package/src/editor/i18n/ru/shell.json +182 -0
- package/src/editor/i18n/ru/system.json +14 -0
- package/src/editor/i18n/ru/validation.json +82 -0
- package/src/editor/i18n/server.ts +13 -0
- package/src/editor/i18n/zh/connection.json +136 -0
- package/src/editor/i18n/zh/defaults.json +6 -0
- package/src/editor/i18n/zh/fields.json +130 -0
- package/src/editor/i18n/zh/local.json +49 -0
- package/src/editor/i18n/zh/media.json +166 -0
- package/src/editor/i18n/zh/richtext.json +116 -0
- package/src/editor/i18n/zh/shell.json +182 -0
- package/src/editor/i18n/zh/system.json +14 -0
- package/src/editor/i18n/zh/validation.json +82 -0
- package/src/editor/lib/ActionDialog.svelte +5 -4
- package/src/editor/lib/BlockEditor.svelte +305 -88
- package/src/editor/lib/CollectionPanel.svelte +17 -15
- package/src/editor/lib/DatePicker.svelte +15 -12
- package/src/editor/lib/ExtensionMount.svelte +12 -0
- package/src/editor/lib/Field.svelte +3 -2
- package/src/editor/lib/ImagePicker.svelte +82 -81
- package/src/editor/lib/MarkdownEditor.svelte +25 -24
- package/src/editor/lib/MediaPicker.svelte +6 -5
- package/src/editor/lib/MenuEditor.svelte +31 -30
- package/src/editor/lib/PreviewFrame.svelte +11 -6
- package/src/editor/lib/PropertiesTabs.svelte +3 -2
- package/src/editor/lib/PublishDialog.svelte +15 -14
- package/src/editor/lib/ReferenceSelect.svelte +3 -2
- package/src/editor/lib/SchemaField.svelte +15 -13
- package/src/editor/lib/SchemaPanel.svelte +20 -19
- package/src/editor/lib/Select.svelte +5 -4
- package/src/editor/lib/SeoGuidance.svelte +6 -5
- package/src/editor/lib/Settings.svelte +54 -54
- package/src/editor/lib/Shortcuts.svelte +7 -6
- package/src/editor/lib/SitePreview.svelte +10 -9
- package/src/editor/lib/TopBar.svelte +18 -17
- package/src/editor/lib/UnsavedChanges.svelte +7 -6
- package/src/editor/lib/VisualEditor.svelte +19 -18
- package/src/editor/lib/calendar.ts +10 -4
- package/src/editor/lib/embed-preview.ts +23 -5
- package/src/editor/lib/extension-preview.ts +121 -0
- package/src/editor/lib/github-auth.ts +23 -22
- package/src/editor/lib/github-backend.ts +96 -91
- package/src/editor/lib/images.ts +33 -31
- package/src/editor/lib/menu-tree.ts +5 -4
- package/src/editor/lib/preview-frame.ts +4 -3
- package/src/editor/lib/schema-edit.ts +3 -2
- package/src/editor/lib/settings.ts +5 -3
- package/src/editor/lib/slash-command.ts +1 -0
- package/src/editor/lib/tooltip.ts +1 -1
- package/src/editor/main.ts +9 -0
- package/src/editor/styles.css +15 -3
- package/src/env.d.ts +11 -1
- package/src/extensions.ts +160 -0
- package/src/index.ts +1 -1
- package/src/manifest/collections.ts +6 -5
- package/src/manifest/content-locales.ts +45 -0
- package/src/manifest/menu.ts +12 -10
- package/src/manifest/navigation.ts +13 -8
- package/src/manifest/references.ts +8 -7
- package/src/manifest/seo.ts +4 -3
- package/src/manifest/types.ts +4 -0
- package/src/preview.ts +36 -2
- package/src/routes/local-api.ts +5 -3
- package/src/routes/local-documents.ts +20 -16
- package/src/routes/local-media.ts +21 -16
- package/src/routes/local-menu.ts +9 -7
- package/src/routes/local-post.ts +18 -12
- package/src/routes/media-files.ts +10 -8
- package/src/routes/rigel-page.astro +2 -1
- package/src/schema/store.ts +22 -20
- package/src/schema/types.ts +2 -0
- package/src/schema/validate.ts +73 -69
- package/src/slugs.ts +11 -10
- package/src/vite/manifest-plugin.ts +38 -2
|
@@ -44,6 +44,7 @@ const __rigelReservedSlugs = new Set(documents.filter((doc) => !documentTypes.fi
|
|
|
44
44
|
.map(
|
|
45
45
|
(c) => ` {
|
|
46
46
|
name: ${JSON.stringify(c.name)},
|
|
47
|
+
${c.locale !== undefined ? `locale: ${JSON.stringify(c.locale)},` : ""}
|
|
47
48
|
label: ${JSON.stringify(c.label ?? c.name)},
|
|
48
49
|
listTitle: ${JSON.stringify(c.listTitle)},
|
|
49
50
|
fields: ${JSON.stringify(c.fields)},
|
|
@@ -126,15 +127,48 @@ export const menus = {
|
|
|
126
127
|
},
|
|
127
128
|
},
|
|
128
129
|
resolveId(id) {
|
|
129
|
-
if (id === VIRTUAL_ID || id === CONTENT_ID || id === "virtual:rigel-config") return "\0" + id;
|
|
130
|
+
if (id === "virtual:rigel-extensions" || id === VIRTUAL_ID || id === CONTENT_ID || id === "virtual:rigel-config" || id === "virtual:rigel-i18n") return "\0" + id;
|
|
130
131
|
},
|
|
131
132
|
load(id) {
|
|
133
|
+
if (id === "\0virtual:rigel-extensions") {
|
|
134
|
+
if (!cfg.extensions!.length) return "export default [];";
|
|
135
|
+
if (!root) throw new Error("rigel: extensions require the Astro project root");
|
|
136
|
+
const directory = fileURLToPath(root);
|
|
137
|
+
const imports = cfg.extensions!.map((module, index) => {
|
|
138
|
+
let filename = directory;
|
|
139
|
+
for (const part of module.slice(2).split("/")) {
|
|
140
|
+
filename = path.join(filename, part);
|
|
141
|
+
try {
|
|
142
|
+
if (lstatSync(filename).isSymbolicLink()) throw new Error("rigel: extension paths must not contain symlinks");
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return `import __rigelExtension${index} from ${JSON.stringify(filename)};`;
|
|
148
|
+
});
|
|
149
|
+
return `${imports.join("\n")}\nexport default [${cfg.extensions!.map((_, index) => `__rigelExtension${index}`).join(", ")}];`;
|
|
150
|
+
}
|
|
151
|
+
if (id === "\0virtual:rigel-i18n") {
|
|
152
|
+
const imports: string[] = [];
|
|
153
|
+
const dictionaries = cfg.languages!.map((language, index) => {
|
|
154
|
+
const directory = fileURLToPath(new URL(`../editor/i18n/${language}/`, import.meta.url));
|
|
155
|
+
const catalogs = readdirSync(directory).filter(file => file.endsWith(".json")).sort().map((file, catalog) => {
|
|
156
|
+
const name = `__rigelLocale${index}_${catalog}`;
|
|
157
|
+
imports.push(`import ${name} from ${JSON.stringify(path.join(directory, file))};`);
|
|
158
|
+
return `...${name}`;
|
|
159
|
+
});
|
|
160
|
+
return `${JSON.stringify(language)}: { ${catalogs.join(", ")} }`;
|
|
161
|
+
});
|
|
162
|
+
return `${imports.join("\n")}\nexport default { ${dictionaries.join(", ")} };`;
|
|
163
|
+
}
|
|
132
164
|
if (id === "\0virtual:rigel-config") {
|
|
133
165
|
return `export default ${JSON.stringify({
|
|
134
166
|
copyDir: cfg.copyDir,
|
|
135
167
|
backend: cfg.backend,
|
|
136
168
|
jsonOutput: cfg.jsonOutput,
|
|
137
169
|
demo: cfg.demo,
|
|
170
|
+
languages: cfg.languages,
|
|
171
|
+
contentLocales: cfg.contentLocales,
|
|
138
172
|
publicDir: publicDir?.href,
|
|
139
173
|
mediaDir: cfg.mediaDir,
|
|
140
174
|
maxFileSize: cfg.maxFileSize,
|
|
@@ -173,8 +207,10 @@ export function derefDocument(value) { return deref(value, __rigelIndex); }
|
|
|
173
207
|
return `
|
|
174
208
|
import { validateBody as __rigelValidateBody } from ${JSON.stringify(fileURLToPath(new URL("../article-body.ts", import.meta.url)))};
|
|
175
209
|
import { validateCollectionValues as __rigelValidateCollectionValues } from ${JSON.stringify(fileURLToPath(new URL("../manifest/collections.ts", import.meta.url)))};
|
|
210
|
+
import { validateContentLocale as __rigelValidateContentLocale } from ${JSON.stringify(fileURLToPath(new URL("../manifest/content-locales.ts", import.meta.url)))};
|
|
176
211
|
const modules = import.meta.glob(${JSON.stringify(pattern)}, { eager: true });
|
|
177
212
|
const loaded = Object.values(modules).map((m) => m.default);
|
|
213
|
+
for (const page of loaded) __rigelValidateContentLocale(page.locale, ${JSON.stringify(cfg.contentLocales)}, page.slug);
|
|
178
214
|
${documentsSrc}
|
|
179
215
|
export const pages = loaded.filter((page) => !__rigelReservedSlugs.has(page.slug)).sort((a, b) => a.slug.localeCompare(b.slug));
|
|
180
216
|
export const collections = [
|
|
@@ -182,7 +218,7 @@ ${collectionCode}
|
|
|
182
218
|
];
|
|
183
219
|
for (const collection of collections) __rigelAssertUniqueUrlSlugs(collection.posts.map(post => ({ slug: post.slug, values: post.frontmatter })));
|
|
184
220
|
${menuCode}
|
|
185
|
-
export default { pages, collections, documents${github ? ', backend: "github", github: ' + JSON.stringify(github) : ""}${cfg.menus ? ", menus" : ""}${cfg.schema ? ", schema: " + JSON.stringify(cfg.schema) : ""}${cfg.preview ? ", preview: " + JSON.stringify(cfg.preview) : ""}${cfg.sidebar ? ", sidebar: " + JSON.stringify(cfg.sidebar) : ""} };
|
|
221
|
+
export default { pages, collections, documents${cfg.contentLocales ? ", contentLocales: " + JSON.stringify(cfg.contentLocales) : ""}${github ? ', backend: "github", github: ' + JSON.stringify(github) : ""}${cfg.menus ? ", menus" : ""}${cfg.schema ? ", schema: " + JSON.stringify(cfg.schema) : ""}${cfg.preview ? ", preview: " + JSON.stringify(cfg.preview) : ""}${cfg.sidebar ? ", sidebar: " + JSON.stringify(cfg.sidebar) : ""} };
|
|
186
222
|
`;
|
|
187
223
|
},
|
|
188
224
|
};
|