@stelstone/server 0.31.0 → 0.32.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stelstone/server",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Runtime-agnostic CMS server built on the Web Fetch API, with pluggable adapters for content, media, auth, and build.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -49,8 +49,9 @@ export function createFsJsonContent({
49
49
  }
50
50
  }
51
51
 
52
- function git(cmd) {
53
- return execSync(`git ${cmd}`, { cwd: rootDir, encoding: "utf-8" }).trim();
52
+ function git(cmd, { trim = true } = {}) {
53
+ const out = execSync(`git ${cmd}`, { cwd: rootDir, encoding: "utf-8" });
54
+ return trim ? out.trim() : out;
54
55
  }
55
56
 
56
57
  function pagePath(collection, file) {
@@ -206,7 +207,11 @@ export function createFsJsonContent({
206
207
  capabilities: { deferredPublish: true, perEntryPublish: true },
207
208
 
208
209
  async pendingChanges() {
209
- const status = git(`status --porcelain ${PATHS_ARG}`);
210
+ // Untrimmed: a modified file's line starts with a space (" M path") and
211
+ // trimming ate it on the first line, which then lost the first letter
212
+ // of its path and was never attributed to its collection — so the
213
+ // first pending entry in a list never got its badge.
214
+ const status = git(`status --porcelain ${PATHS_ARG}`, { trim: false });
210
215
  const lines = status.split("\n").filter(Boolean);
211
216
  // Porcelain line: "XY path" (rename: "XY old -> new"). Only entries under
212
217
  // pagesDir are attributed to a collection/file; other publishPaths (e.g.
package/src/routes.mjs CHANGED
@@ -311,9 +311,20 @@ export const apiRoutes = [
311
311
  if (!data) return notFound();
312
312
 
313
313
  let url = null;
314
+ // Which publish target the preview shows, when the site can say: a
315
+ // draft previews on the staging site, a published entry on the live
316
+ // one. The admin needs this to tell whether the framed page is current
317
+ // or behind the saved draft.
318
+ let target = null;
314
319
  if (typeof config.previewUrl === "function") {
315
320
  try {
316
- url = config.previewUrl({ collection: params.collection, data });
321
+ const out = config.previewUrl({ collection: params.collection, data });
322
+ if (out && typeof out === "object") {
323
+ url = out.url ?? null;
324
+ target = out.target ?? null;
325
+ } else {
326
+ url = out;
327
+ }
317
328
  } catch (err) {
318
329
  return { status: 500, json: { error: `previewUrl(): ${err.message}` } };
319
330
  }
@@ -323,7 +334,7 @@ export const apiRoutes = [
323
334
  .replace("{slug}", data.slug || "")
324
335
  .replace("{lang}", data.lang || "");
325
336
  }
326
- return ok({ url });
337
+ return ok({ url, target });
327
338
  },
328
339
  },
329
340
 
package/src/version.mjs CHANGED
@@ -5,4 +5,4 @@
5
5
  * require() and no import.meta.url, so reading the manifest at runtime yields
6
6
  * "unknown" there.
7
7
  */
8
- export const SERVER_VERSION = "0.31.0";
8
+ export const SERVER_VERSION = "0.32.0";