@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.
Files changed (159) hide show
  1. package/README.md +8 -0
  2. package/docs/content-locales.md +53 -0
  3. package/docs/extensions.md +194 -0
  4. package/package.json +16 -3
  5. package/src/article-body.ts +49 -37
  6. package/src/article-render.ts +25 -2
  7. package/src/article.ts +44 -0
  8. package/src/config.ts +26 -2
  9. package/src/editor/App.svelte +149 -107
  10. package/src/editor/blocks/extension.ts +29 -0
  11. package/src/editor/blocks/index.ts +17 -15
  12. package/src/editor/blocks/video.ts +2 -1
  13. package/src/editor/i18n/README.md +23 -0
  14. package/src/editor/i18n/de/connection.json +136 -0
  15. package/src/editor/i18n/de/defaults.json +6 -0
  16. package/src/editor/i18n/de/fields.json +130 -0
  17. package/src/editor/i18n/de/local.json +49 -0
  18. package/src/editor/i18n/de/media.json +166 -0
  19. package/src/editor/i18n/de/richtext.json +116 -0
  20. package/src/editor/i18n/de/shell.json +182 -0
  21. package/src/editor/i18n/de/system.json +14 -0
  22. package/src/editor/i18n/de/validation.json +82 -0
  23. package/src/editor/i18n/en/connection.json +136 -0
  24. package/src/editor/i18n/en/defaults.json +6 -0
  25. package/src/editor/i18n/en/fields.json +130 -0
  26. package/src/editor/i18n/en/local.json +49 -0
  27. package/src/editor/i18n/en/media.json +166 -0
  28. package/src/editor/i18n/en/richtext.json +116 -0
  29. package/src/editor/i18n/en/shell.json +182 -0
  30. package/src/editor/i18n/en/system.json +14 -0
  31. package/src/editor/i18n/en/validation.json +82 -0
  32. package/src/editor/i18n/es/connection.json +136 -0
  33. package/src/editor/i18n/es/defaults.json +6 -0
  34. package/src/editor/i18n/es/fields.json +130 -0
  35. package/src/editor/i18n/es/local.json +49 -0
  36. package/src/editor/i18n/es/media.json +166 -0
  37. package/src/editor/i18n/es/richtext.json +116 -0
  38. package/src/editor/i18n/es/shell.json +182 -0
  39. package/src/editor/i18n/es/system.json +14 -0
  40. package/src/editor/i18n/es/validation.json +82 -0
  41. package/src/editor/i18n/format.ts +26 -0
  42. package/src/editor/i18n/fr/connection.json +136 -0
  43. package/src/editor/i18n/fr/defaults.json +6 -0
  44. package/src/editor/i18n/fr/fields.json +130 -0
  45. package/src/editor/i18n/fr/local.json +49 -0
  46. package/src/editor/i18n/fr/media.json +166 -0
  47. package/src/editor/i18n/fr/richtext.json +116 -0
  48. package/src/editor/i18n/fr/shell.json +182 -0
  49. package/src/editor/i18n/fr/system.json +14 -0
  50. package/src/editor/i18n/fr/validation.json +82 -0
  51. package/src/editor/i18n/index.ts +18 -0
  52. package/src/editor/i18n/it/connection.json +136 -0
  53. package/src/editor/i18n/it/defaults.json +6 -0
  54. package/src/editor/i18n/it/fields.json +130 -0
  55. package/src/editor/i18n/it/local.json +49 -0
  56. package/src/editor/i18n/it/media.json +166 -0
  57. package/src/editor/i18n/it/richtext.json +116 -0
  58. package/src/editor/i18n/it/shell.json +182 -0
  59. package/src/editor/i18n/it/system.json +14 -0
  60. package/src/editor/i18n/it/validation.json +82 -0
  61. package/src/editor/i18n/ja/connection.json +136 -0
  62. package/src/editor/i18n/ja/defaults.json +6 -0
  63. package/src/editor/i18n/ja/fields.json +130 -0
  64. package/src/editor/i18n/ja/local.json +49 -0
  65. package/src/editor/i18n/ja/media.json +166 -0
  66. package/src/editor/i18n/ja/richtext.json +116 -0
  67. package/src/editor/i18n/ja/shell.json +182 -0
  68. package/src/editor/i18n/ja/system.json +14 -0
  69. package/src/editor/i18n/ja/validation.json +82 -0
  70. package/src/editor/i18n/locales.ts +13 -0
  71. package/src/editor/i18n/nl/connection.json +136 -0
  72. package/src/editor/i18n/nl/defaults.json +6 -0
  73. package/src/editor/i18n/nl/fields.json +130 -0
  74. package/src/editor/i18n/nl/local.json +49 -0
  75. package/src/editor/i18n/nl/media.json +166 -0
  76. package/src/editor/i18n/nl/richtext.json +116 -0
  77. package/src/editor/i18n/nl/shell.json +182 -0
  78. package/src/editor/i18n/nl/system.json +14 -0
  79. package/src/editor/i18n/nl/validation.json +82 -0
  80. package/src/editor/i18n/ru/connection.json +138 -0
  81. package/src/editor/i18n/ru/defaults.json +6 -0
  82. package/src/editor/i18n/ru/fields.json +132 -0
  83. package/src/editor/i18n/ru/local.json +49 -0
  84. package/src/editor/i18n/ru/media.json +166 -0
  85. package/src/editor/i18n/ru/richtext.json +116 -0
  86. package/src/editor/i18n/ru/shell.json +182 -0
  87. package/src/editor/i18n/ru/system.json +14 -0
  88. package/src/editor/i18n/ru/validation.json +82 -0
  89. package/src/editor/i18n/server.ts +13 -0
  90. package/src/editor/i18n/zh/connection.json +136 -0
  91. package/src/editor/i18n/zh/defaults.json +6 -0
  92. package/src/editor/i18n/zh/fields.json +130 -0
  93. package/src/editor/i18n/zh/local.json +49 -0
  94. package/src/editor/i18n/zh/media.json +166 -0
  95. package/src/editor/i18n/zh/richtext.json +116 -0
  96. package/src/editor/i18n/zh/shell.json +182 -0
  97. package/src/editor/i18n/zh/system.json +14 -0
  98. package/src/editor/i18n/zh/validation.json +82 -0
  99. package/src/editor/lib/ActionDialog.svelte +5 -4
  100. package/src/editor/lib/BlockEditor.svelte +305 -88
  101. package/src/editor/lib/CollectionPanel.svelte +17 -15
  102. package/src/editor/lib/DatePicker.svelte +15 -12
  103. package/src/editor/lib/ExtensionMount.svelte +12 -0
  104. package/src/editor/lib/Field.svelte +3 -2
  105. package/src/editor/lib/ImagePicker.svelte +82 -81
  106. package/src/editor/lib/MarkdownEditor.svelte +25 -24
  107. package/src/editor/lib/MediaPicker.svelte +6 -5
  108. package/src/editor/lib/MenuEditor.svelte +31 -30
  109. package/src/editor/lib/PreviewFrame.svelte +11 -6
  110. package/src/editor/lib/PropertiesTabs.svelte +3 -2
  111. package/src/editor/lib/PublishDialog.svelte +15 -14
  112. package/src/editor/lib/ReferenceSelect.svelte +3 -2
  113. package/src/editor/lib/SchemaField.svelte +15 -13
  114. package/src/editor/lib/SchemaPanel.svelte +20 -19
  115. package/src/editor/lib/Select.svelte +5 -4
  116. package/src/editor/lib/SeoGuidance.svelte +6 -5
  117. package/src/editor/lib/Settings.svelte +54 -54
  118. package/src/editor/lib/Shortcuts.svelte +7 -6
  119. package/src/editor/lib/SitePreview.svelte +10 -9
  120. package/src/editor/lib/TopBar.svelte +18 -17
  121. package/src/editor/lib/UnsavedChanges.svelte +7 -6
  122. package/src/editor/lib/VisualEditor.svelte +19 -18
  123. package/src/editor/lib/calendar.ts +10 -4
  124. package/src/editor/lib/embed-preview.ts +23 -5
  125. package/src/editor/lib/extension-preview.ts +121 -0
  126. package/src/editor/lib/github-auth.ts +23 -22
  127. package/src/editor/lib/github-backend.ts +96 -91
  128. package/src/editor/lib/images.ts +33 -31
  129. package/src/editor/lib/menu-tree.ts +5 -4
  130. package/src/editor/lib/preview-frame.ts +4 -3
  131. package/src/editor/lib/schema-edit.ts +3 -2
  132. package/src/editor/lib/settings.ts +5 -3
  133. package/src/editor/lib/slash-command.ts +1 -0
  134. package/src/editor/lib/tooltip.ts +1 -1
  135. package/src/editor/main.ts +9 -0
  136. package/src/editor/styles.css +15 -3
  137. package/src/env.d.ts +11 -1
  138. package/src/extensions.ts +160 -0
  139. package/src/index.ts +1 -1
  140. package/src/manifest/collections.ts +6 -5
  141. package/src/manifest/content-locales.ts +45 -0
  142. package/src/manifest/menu.ts +12 -10
  143. package/src/manifest/navigation.ts +13 -8
  144. package/src/manifest/references.ts +8 -7
  145. package/src/manifest/seo.ts +4 -3
  146. package/src/manifest/types.ts +4 -0
  147. package/src/preview.ts +36 -2
  148. package/src/routes/local-api.ts +5 -3
  149. package/src/routes/local-documents.ts +20 -16
  150. package/src/routes/local-media.ts +21 -16
  151. package/src/routes/local-menu.ts +9 -7
  152. package/src/routes/local-post.ts +18 -12
  153. package/src/routes/media-files.ts +10 -8
  154. package/src/routes/rigel-page.astro +2 -1
  155. package/src/schema/store.ts +22 -20
  156. package/src/schema/types.ts +2 -0
  157. package/src/schema/validate.ts +73 -69
  158. package/src/slugs.ts +11 -10
  159. 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
  };