@webnumseoagent/next 0.1.20 → 0.1.22

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/client.ts CHANGED
@@ -20,7 +20,11 @@ interface SeoFields {
20
20
  title?: string;
21
21
  description?: string;
22
22
  canonical?: string;
23
- robots?: { index?: boolean; follow?: boolean; noarchive?: boolean; nosnippet?: boolean; noimageindex?: boolean };
23
+ robots?: {
24
+ index?: boolean; follow?: boolean; noarchive?: boolean; nosnippet?: boolean; noimageindex?: boolean;
25
+ // Расширенные директивы (RankMath «Advanced Robots»): предел сниппета, превью видео, размер превью картинок.
26
+ maxSnippet?: number; maxVideoPreview?: number; maxImagePreview?: "none" | "standard" | "large";
27
+ };
24
28
  og?: { title?: string; description?: string; image?: string; siteName?: string; locale?: string };
25
29
  twitter?: { card?: string; image?: string; site?: string };
26
30
  facebook?: { appId?: string; admins?: string }; // fb:app_id / fb:admins (admins — через запятую)
@@ -154,6 +158,15 @@ function mergeIntoMetadata(fallback: Metadata, f: SeoFields, route: string): Met
154
158
  m.description = f.description;
155
159
  }
156
160
  if (f.canonical) m.alternates = { ...(m.alternates ?? {}), canonical: f.canonical };
161
+ // Авто self-canonical: если ни сайт (fallback), ни конфиг не задали canonical — ставим ссылку на
162
+ // саму страницу. Существующий canonical НЕ трогаем (сайт может каноникалить на другой URL — дедуп).
163
+ // Путь нормализуем к ведущему «/»; при заданном baseUrl делаем абсолютным, иначе относительный —
164
+ // он тоже даёт верный self-canonical (резолвится к URL страницы / через metadataBase сайта).
165
+ if (!m.alternates?.canonical) {
166
+ const path = "/" + String(route ?? "").replace(/^\/+/, "");
167
+ const self = f.baseUrl ? f.baseUrl.replace(/\/+$/, "") + path : path;
168
+ m.alternates = { ...(m.alternates ?? {}), canonical: self };
169
+ }
157
170
  if (f.robots) {
158
171
  const r = f.robots;
159
172
  const base: Record<string, unknown> =
@@ -165,6 +178,10 @@ function mergeIntoMetadata(fallback: Metadata, f: SeoFields, route: string): Met
165
178
  if (r.noarchive) base.noarchive = true;
166
179
  if (r.nosnippet) base.nosnippet = true;
167
180
  if (r.noimageindex) base.noimageindex = true;
181
+ // Расширенные директивы — ключи с дефисом, как их ждёт Next (эмитятся в <meta name="robots">).
182
+ if (typeof r.maxSnippet === "number") base["max-snippet"] = r.maxSnippet;
183
+ if (typeof r.maxVideoPreview === "number") base["max-video-preview"] = r.maxVideoPreview;
184
+ if (r.maxImagePreview) base["max-image-preview"] = r.maxImagePreview;
168
185
  m.robots = base as Metadata["robots"];
169
186
  }
170
187
  if (f.og) {
package/dist/client.js CHANGED
@@ -157,6 +157,15 @@ function mergeIntoMetadata(fallback, f, route) {
157
157
  }
158
158
  if (f.canonical)
159
159
  m.alternates = { ...(m.alternates ?? {}), canonical: f.canonical };
160
+ // Авто self-canonical: если ни сайт (fallback), ни конфиг не задали canonical — ставим ссылку на
161
+ // саму страницу. Существующий canonical НЕ трогаем (сайт может каноникалить на другой URL — дедуп).
162
+ // Путь нормализуем к ведущему «/»; при заданном baseUrl делаем абсолютным, иначе относительный —
163
+ // он тоже даёт верный self-canonical (резолвится к URL страницы / через metadataBase сайта).
164
+ if (!m.alternates?.canonical) {
165
+ const path = "/" + String(route ?? "").replace(/^\/+/, "");
166
+ const self = f.baseUrl ? f.baseUrl.replace(/\/+$/, "") + path : path;
167
+ m.alternates = { ...(m.alternates ?? {}), canonical: self };
168
+ }
160
169
  if (f.robots) {
161
170
  const r = f.robots;
162
171
  const base = typeof m.robots === "string" ? robotsFromString(m.robots)
@@ -172,6 +181,13 @@ function mergeIntoMetadata(fallback, f, route) {
172
181
  base.nosnippet = true;
173
182
  if (r.noimageindex)
174
183
  base.noimageindex = true;
184
+ // Расширенные директивы — ключи с дефисом, как их ждёт Next (эмитятся в <meta name="robots">).
185
+ if (typeof r.maxSnippet === "number")
186
+ base["max-snippet"] = r.maxSnippet;
187
+ if (typeof r.maxVideoPreview === "number")
188
+ base["max-video-preview"] = r.maxVideoPreview;
189
+ if (r.maxImagePreview)
190
+ base["max-image-preview"] = r.maxImagePreview;
175
191
  m.robots = base;
176
192
  }
177
193
  if (f.og) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webnumseoagent/next",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Runtime SEO adapter + installer for Next.js App Router sites (SEO Agent platform)",
5
5
  "main": "dist/client.js",
6
6
  "types": "dist/client.d.ts",