@easy-cms/plugin-seo 1.4.0 → 1.4.2
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/dist/index.d.ts +27 -12
- package/dist/index.js +14 -4
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -207,13 +207,22 @@ interface NuxtSeoMeta {
|
|
|
207
207
|
twitterDescription?: string;
|
|
208
208
|
twitterImage?: string;
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* A link in `NuxtSeoHead`: the canonical one, or the page in another locale. One type per `rel`,
|
|
212
|
+
* as unhead (Nuxt's `useHead()`) types them.
|
|
213
|
+
*/
|
|
214
|
+
type NuxtSeoLink = {
|
|
215
|
+
rel: 'canonical';
|
|
216
|
+
href: string;
|
|
217
|
+
hreflang?: undefined;
|
|
218
|
+
} | {
|
|
219
|
+
rel: 'alternate';
|
|
220
|
+
href: string;
|
|
221
|
+
hreflang: string;
|
|
222
|
+
};
|
|
210
223
|
/** Input for Nuxt's `useHead()`: the canonical and hreflang links, and the JSON-LD script. */
|
|
211
224
|
interface NuxtSeoHead {
|
|
212
|
-
link:
|
|
213
|
-
rel: 'canonical' | 'alternate';
|
|
214
|
-
href: string;
|
|
215
|
-
hreflang?: string;
|
|
216
|
-
}[];
|
|
225
|
+
link: NuxtSeoLink[];
|
|
217
226
|
script: {
|
|
218
227
|
type: 'application/ld+json';
|
|
219
228
|
innerHTML: string;
|
|
@@ -370,7 +379,13 @@ interface GenerateArgs {
|
|
|
370
379
|
readonly cms: EasyCMS;
|
|
371
380
|
readonly user: AuthUser | null;
|
|
372
381
|
}
|
|
373
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Suggests a value from the document. `doc` isn't typed from the collection (the plugin is set
|
|
384
|
+
* up before the config it belongs to), so a generator may return a field as read, e.g.
|
|
385
|
+
* `({ doc }) => doc.excerpt`: text for titles, descriptions and URLs, a media id (or media
|
|
386
|
+
* document) for the image. Other values suggest nothing.
|
|
387
|
+
*/
|
|
388
|
+
type Generate<T = unknown> = (args: GenerateArgs) => MaybePromise<T | null | undefined>;
|
|
374
389
|
interface SeoPluginOptions {
|
|
375
390
|
/** Collections that get SEO fields, by slug. */
|
|
376
391
|
readonly collections?: readonly string[];
|
|
@@ -385,13 +400,13 @@ interface SeoPluginOptions {
|
|
|
385
400
|
*/
|
|
386
401
|
readonly tab?: boolean | Label$1;
|
|
387
402
|
/** Suggests a meta title, e.g. `({ doc }) => \`${doc.title} | My Blog\``. Adds a Generate button. */
|
|
388
|
-
readonly generateTitle?: Generate
|
|
403
|
+
readonly generateTitle?: Generate;
|
|
389
404
|
/** Suggests a meta description, e.g. from an excerpt. Adds a Generate button. */
|
|
390
|
-
readonly generateDescription?: Generate
|
|
391
|
-
/** Suggests a share image:
|
|
392
|
-
readonly generateImage?: Generate
|
|
405
|
+
readonly generateDescription?: Generate;
|
|
406
|
+
/** Suggests a share image: a media document or its id, e.g. the post's cover. */
|
|
407
|
+
readonly generateImage?: Generate;
|
|
393
408
|
/** The page's address (absolute, or a path on `admin.siteURL`), shown in the search preview. */
|
|
394
|
-
readonly generateURL?: Generate
|
|
409
|
+
readonly generateURL?: Generate;
|
|
395
410
|
/** Fill empty meta fields with the generators when a document is saved. Default false. */
|
|
396
411
|
readonly autoGenerate?: boolean;
|
|
397
412
|
/** Changes the fields of the group, e.g. `(defaults) => [...defaults, noindexField]`. */
|
|
@@ -520,4 +535,4 @@ declare function sitemap(cms: SeoCMS, options?: SitemapOptions): Promise<Sitemap
|
|
|
520
535
|
*/
|
|
521
536
|
declare function sitemapXml(cms: SeoCMS, options?: SitemapXmlOptions): Promise<string>;
|
|
522
537
|
|
|
523
|
-
export { AI_CRAWLERS, DEFAULT_DESCRIPTION_LENGTH, DEFAULT_TITLE_LENGTH, type DocMarkdownOptions, type Generate, type GenerateArgs, type IndexNowOptions, type JsonLd, type LlmsFullTxtOptions, type LlmsOptions, type LlmsTxtOptions, type NextSeoMetadata, type NuxtSeoHead, type NuxtSeoMeta, type RobotsRule, type RobotsTxtOptions, SITEMAP_LIMIT, type SeoBreadcrumb, type SeoImage, type SeoMeta, type SeoMetaField, type SeoMetaOptions, type SeoPluginOptions, type SeoPluginTypes, type SiteJsonLdOptions, type SitemapEntry, type SitemapOptions, type SitemapXmlOptions, docMarkdown, indexNowKeyFile, jsonLdScript, llmsFullTxt, llmsTxt, robotsTxt, seoMeta, seoPlugin, siteJsonLd, sitemap, sitemapXml };
|
|
538
|
+
export { AI_CRAWLERS, DEFAULT_DESCRIPTION_LENGTH, DEFAULT_TITLE_LENGTH, type DocMarkdownOptions, type Generate, type GenerateArgs, type IndexNowOptions, type JsonLd, type LlmsFullTxtOptions, type LlmsOptions, type LlmsTxtOptions, type NextSeoMetadata, type NuxtSeoHead, type NuxtSeoLink, type NuxtSeoMeta, type RobotsRule, type RobotsTxtOptions, SITEMAP_LIMIT, type SeoBreadcrumb, type SeoImage, type SeoMeta, type SeoMetaField, type SeoMetaOptions, type SeoPluginOptions, type SeoPluginTypes, type SiteJsonLdOptions, type SitemapEntry, type SitemapOptions, type SitemapXmlOptions, docMarkdown, indexNowKeyFile, jsonLdScript, llmsFullTxt, llmsTxt, robotsTxt, seoMeta, seoPlugin, siteJsonLd, sitemap, sitemapXml };
|
package/dist/index.js
CHANGED
|
@@ -524,7 +524,7 @@ var INFO = {
|
|
|
524
524
|
name: "@easy-cms/plugin-seo",
|
|
525
525
|
// The plugin API it is written for (`PLUGIN_API_VERSION` of @easy-cms/core).
|
|
526
526
|
apiVersion: 1,
|
|
527
|
-
...true ? { version: "1.4.
|
|
527
|
+
...true ? { version: "1.4.2" } : {}
|
|
528
528
|
};
|
|
529
529
|
|
|
530
530
|
// src/robots.ts
|
|
@@ -663,6 +663,13 @@ var xml = (value) => value.replace(
|
|
|
663
663
|
);
|
|
664
664
|
|
|
665
665
|
// src/plugin.ts
|
|
666
|
+
function suggestion(kind, value) {
|
|
667
|
+
if (kind === "image") {
|
|
668
|
+
const id = typeof value === "object" && value !== null && "id" in value ? value.id : value;
|
|
669
|
+
return typeof id === "string" && id !== "" || typeof id === "number" ? id : null;
|
|
670
|
+
}
|
|
671
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
672
|
+
}
|
|
666
673
|
var ADMIN_MODULE = "@easy-cms/plugin-seo/admin";
|
|
667
674
|
var TEXT_KINDS = ["title", "description"];
|
|
668
675
|
function seoPlugin(options = {}) {
|
|
@@ -758,8 +765,11 @@ function seoPlugin(options = {}) {
|
|
|
758
765
|
const generate = generators[kind];
|
|
759
766
|
if (!generate || !isEmpty(meta[kind])) continue;
|
|
760
767
|
const id = previousDoc?.id ?? null;
|
|
761
|
-
const value =
|
|
762
|
-
|
|
768
|
+
const value = suggestion(
|
|
769
|
+
kind,
|
|
770
|
+
await generate({ doc, id, locale: null, cms, user, ...target })
|
|
771
|
+
);
|
|
772
|
+
if (value !== null) meta[kind] = value;
|
|
763
773
|
}
|
|
764
774
|
return { ...data, [META_FIELD]: meta };
|
|
765
775
|
} : void 0;
|
|
@@ -866,7 +876,7 @@ function seoPlugin(options = {}) {
|
|
|
866
876
|
user,
|
|
867
877
|
...collection ? { collection } : { global }
|
|
868
878
|
});
|
|
869
|
-
return { value: value
|
|
879
|
+
return { value: suggestion(kind, value) };
|
|
870
880
|
}
|
|
871
881
|
};
|
|
872
882
|
const source = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/plugin-seo",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "SEO for Easy CMS: meta fields, length meters, a search result preview, generators and page metadata",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@easy-cms/richtext": "^1.4.
|
|
20
|
+
"@easy-cms/richtext": "^1.4.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@easy-cms/core": "^1.4.
|
|
23
|
+
"@easy-cms/core": "^1.4.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"happy-dom": "^20.14.5",
|
|
27
|
-
"@easy-cms/core": "^1.4.
|
|
28
|
-
"@easy-cms/db-sqlite": "^1.4.
|
|
27
|
+
"@easy-cms/core": "^1.4.2",
|
|
28
|
+
"@easy-cms/db-sqlite": "^1.4.2"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=22.12"
|