@webnumseoagent/next 0.1.0 → 0.1.1

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/bin/cli.mjs CHANGED
@@ -173,7 +173,7 @@ async function init() {
173
173
  }
174
174
  }
175
175
 
176
- log(`\n И смонтируй JSON-LD в layout (внутри <body>):\n \x1b[36mimport { SeoJsonLd } from "${importJsonld}";\n <SeoJsonLd route="/" locale={locale} />\x1b[0m`);
176
+ log(`\n И смонтируй JSON-LD в layout (внутри <body>):\n \x1b[36mimport { SeoJsonLd } from "${importJsonld}";\n <SeoJsonLd route="/" />\x1b[0m`);
177
177
  log("\n\x1b[1mЗатем:\x1b[0m задай эти же env-переменные в Vercel (Settings → Environment Variables) и сделай git push.\n");
178
178
  }
179
179
 
package/bin/wrap.mjs CHANGED
@@ -50,7 +50,9 @@ export async function wrapFile(code, routeExpr, importSpec) {
50
50
  }
51
51
  }
52
52
  if (!fn || !fn.body) return { ok: false, reason: "no-generateMetadata" };
53
- if (!/\blocale\b/.test(code)) return { ok: false, reason: "no-locale-binding" };
53
+ // locale опционально: включаем его в seoMeta только если он есть в scope
54
+ // (мультиязычные сайты), для одноязычных — опускаем.
55
+ const hasLocale = /\blocale\b/.test(code);
54
56
 
55
57
  // Динамические параметры маршрута (напр. slug) должны быть в scope.
56
58
  for (const m of routeExpr.matchAll(/\$\{(\w+)\}/g)) {
@@ -61,10 +63,11 @@ export async function wrapFile(code, routeExpr, importSpec) {
61
63
  if (!returns.length) return { ok: false, reason: "no-object-return" };
62
64
  const target = returns[returns.length - 1];
63
65
 
64
- // Строим seoMeta({ route, locale, fallback: <оригинальный объект> })
66
+ // Строим seoMeta({ route, [locale,] fallback: <оригинальный объект> })
65
67
  let call;
66
68
  try {
67
- call = babelParser.parseExpression(`seoMeta({ route: ${routeExpr}, locale, fallback: null })`, { plugins });
69
+ const localePart = hasLocale ? "locale, " : "";
70
+ call = babelParser.parseExpression(`seoMeta({ route: ${routeExpr}, ${localePart}fallback: null })`, { plugins });
68
71
  } catch { return { ok: false, reason: "route-expr" }; }
69
72
  const fbProp = call.arguments[0].properties.find((p) => p.key && p.key.name === "fallback");
70
73
  fbProp.value = target.argument; // подставляем прежний объект как fallback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webnumseoagent/next",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Runtime SEO adapter + installer for Next.js App Router sites (SEO Agent platform)",
5
5
  "type": "module",
6
6
  "main": "dist/client.js",