@yourbright/emdash-analytics-plugin 0.1.8 → 0.1.9

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 (2) hide show
  1. package/dist/index.js +2 -51
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -297,27 +297,6 @@ async function getManagedContentMap(siteOrigin) {
297
297
  void siteOrigin;
298
298
  return managed;
299
299
  }
300
- async function resolveManagedContent(collection, id, slug, siteOrigin) {
301
- if (collection !== "posts") return null;
302
- const ref = id || slug;
303
- if (!ref) return null;
304
- const result = await getEmDashEntry("posts", ref);
305
- const entry = result.entry;
306
- if (!entry) return null;
307
- const entryId = typeof entry.id === "string" ? entry.id : ref;
308
- const entrySlug = typeof entry.slug === "string" ? entry.slug : null;
309
- const data = entry.data ?? {};
310
- const urlPath = `/blog/${entrySlug || entryId}/`;
311
- return {
312
- collection: "posts",
313
- id: entryId,
314
- slug: entrySlug,
315
- urlPath,
316
- title: typeof data.title === "string" ? data.title : entrySlug || entryId,
317
- excerpt: typeof data.excerpt === "string" ? data.excerpt : void 0,
318
- seoDescription: typeof data.seo_description === "string" ? data.seo_description : void 0
319
- };
320
- }
321
300
  function pageStorageId(urlPath) {
322
301
  return stableStorageId(urlPath);
323
302
  }
@@ -1073,15 +1052,7 @@ async function getContentContext(ctx, collection, id, slug) {
1073
1052
  if (!page) {
1074
1053
  throw new PluginRouteError("NOT_FOUND", "Analytics data not found for content", 404);
1075
1054
  }
1076
- const contentRef = await resolveContentRef(config.siteOrigin, page, collection, id, slug) || {
1077
- collection: "posts",
1078
- id: page.contentId || id || pageStorageId(page.urlPath),
1079
- slug: page.contentSlug || slug || null,
1080
- urlPath: page.urlPath,
1081
- title: page.title,
1082
- excerpt: void 0,
1083
- seoDescription: void 0
1084
- };
1055
+ const contentRef = resolveStoredContentRef(page, collection, id, slug);
1085
1056
  const queries = await getFreshQueriesForPage(ctx, config, contentRef.urlPath);
1086
1057
  const windows = buildWindows();
1087
1058
  const score = scorePage(page, queries);
@@ -1231,27 +1202,7 @@ async function findContentPage(ctx, collection, id, slug) {
1231
1202
  }
1232
1203
  return null;
1233
1204
  }
1234
- async function resolveContentRef(siteOrigin, page, collection, id, slug) {
1235
- if (collection !== "posts") {
1236
- return {
1237
- collection: "posts",
1238
- id: page.contentId || id || pageStorageId(page.urlPath),
1239
- slug: page.contentSlug || slug || null,
1240
- urlPath: page.urlPath,
1241
- title: page.title,
1242
- excerpt: void 0,
1243
- seoDescription: void 0
1244
- };
1245
- }
1246
- const resolved = await resolveManagedContent(
1247
- collection,
1248
- page.contentId || id,
1249
- page.contentSlug || slug || void 0,
1250
- siteOrigin
1251
- );
1252
- if (resolved) {
1253
- return resolved;
1254
- }
1205
+ function resolveStoredContentRef(page, collection, id, slug) {
1255
1206
  return {
1256
1207
  collection: "posts",
1257
1208
  id: page.contentId || id || pageStorageId(page.urlPath),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yourbright/emdash-analytics-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Google Search Console and GA4 analytics plugin for EmDash",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",