@umituz/web-seo 2.0.21 → 2.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/dist/domains/seo/components/JsonLd.d.ts +1 -9
- package/dist/domains/seo/components/JsonLd.js +22 -80
- package/dist/domains/seo/components/SEO.js +5 -35
- package/dist/domains/seo/components/index.d.ts +0 -5
- package/dist/domains/seo/components/index.js +0 -5
- package/dist/domains/seo/core/constants.d.ts +9 -0
- package/dist/domains/seo/core/constants.js +9 -0
- package/dist/domains/seo/core/deep-equal.d.ts +1 -0
- package/dist/domains/seo/core/deep-equal.js +21 -0
- package/dist/domains/seo/core/dom-queue.d.ts +3 -0
- package/dist/domains/seo/core/dom-queue.js +27 -0
- package/dist/domains/seo/core/escape.d.ts +2 -0
- package/dist/domains/seo/core/escape.js +31 -0
- package/dist/domains/seo/core/hash.d.ts +1 -0
- package/dist/domains/seo/core/hash.js +21 -0
- package/dist/domains/seo/core/init.d.ts +4 -2
- package/dist/domains/seo/core/init.js +27 -18
- package/dist/domains/seo/core/seo-strategies.d.ts +19 -0
- package/dist/domains/seo/core/seo-strategies.js +620 -0
- package/dist/domains/seo/core/seo-strategy.d.ts +16 -0
- package/dist/domains/seo/core/seo-strategy.js +1 -0
- package/dist/domains/seo/hooks/index.d.ts +0 -5
- package/dist/domains/seo/hooks/index.js +0 -5
- package/dist/domains/seo/hooks/useJsonLd.d.ts +2 -10
- package/dist/domains/seo/hooks/useJsonLd.js +23 -64
- package/dist/domains/seo/hooks/useSEO.js +2 -30
- package/dist/domains/seo/ssr/helmet.d.ts +18 -0
- package/dist/domains/seo/ssr/helmet.js +16 -0
- package/dist/domains/seo/ssr/index.d.ts +5 -0
- package/dist/domains/seo/ssr/index.js +3 -0
- package/dist/domains/seo/ssr/renderer.d.ts +1 -47
- package/dist/domains/seo/ssr/renderer.js +41 -296
- package/dist/domains/seo/ssr/serializer.d.ts +0 -66
- package/dist/domains/seo/ssr/serializer.js +21 -172
- package/dist/domains/seo/types/index.d.ts +0 -4
- package/dist/domains/seo/types/schema.d.ts +22 -3
- package/dist/domains/seo/types/schema.js +0 -3
- package/dist/domains/seo/utils/dom/dom-context.d.ts +2 -0
- package/dist/domains/seo/utils/dom/dom-context.js +48 -0
- package/dist/domains/seo/utils/dom/dom-mutator.d.ts +9 -0
- package/dist/domains/seo/utils/dom/dom-mutator.js +64 -0
- package/dist/domains/seo/utils/dom/index.d.ts +1 -0
- package/dist/domains/seo/utils/dom/index.js +1 -0
- package/dist/domains/seo/utils/index.d.ts +2 -8
- package/dist/domains/seo/utils/index.js +2 -12
- package/dist/domains/seo/utils/schema-generators/base.d.ts +14 -0
- package/dist/domains/seo/utils/schema-generators/base.js +39 -0
- package/dist/domains/seo/utils/schema-generators/factory.d.ts +20 -0
- package/dist/domains/seo/utils/schema-generators/factory.js +42 -0
- package/dist/domains/seo/utils/schema-generators/generators/article.d.ts +4 -0
- package/dist/domains/seo/utils/schema-generators/generators/article.js +39 -0
- package/dist/domains/seo/utils/schema-generators/generators/breadcrumb.d.ts +6 -0
- package/dist/domains/seo/utils/schema-generators/generators/breadcrumb.js +18 -0
- package/dist/domains/seo/utils/schema-generators/generators/course.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/course.js +70 -0
- package/dist/domains/seo/utils/schema-generators/generators/faq.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/faq.js +21 -0
- package/dist/domains/seo/utils/schema-generators/generators/local-business.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/local-business.js +45 -0
- package/dist/domains/seo/utils/schema-generators/generators/organization.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/organization.js +25 -0
- package/dist/domains/seo/utils/schema-generators/generators/person.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/person.js +27 -0
- package/dist/domains/seo/utils/schema-generators/generators/product.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/product.js +40 -0
- package/dist/domains/seo/utils/schema-generators/generators/video.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/video.js +23 -0
- package/dist/domains/seo/utils/schema-generators/generators/website.d.ts +3 -0
- package/dist/domains/seo/utils/schema-generators/generators/website.js +30 -0
- package/dist/domains/seo/utils/schema-generators/index.d.ts +13 -6
- package/dist/domains/seo/utils/schema-generators/index.js +11 -6
- package/dist/domains/seo/utils/schema-generators/types.d.ts +138 -0
- package/dist/domains/seo/utils/schema-generators/types.js +1 -0
- package/dist/domains/seo/utils/validation/hreflang-validator.d.ts +4 -0
- package/dist/domains/seo/utils/validation/hreflang-validator.js +10 -0
- package/dist/domains/seo/utils/validation/image-validator.d.ts +1 -0
- package/dist/domains/seo/utils/validation/image-validator.js +18 -0
- package/dist/domains/seo/utils/validation/index.d.ts +8 -6
- package/dist/domains/seo/utils/validation/index.js +8 -6
- package/dist/domains/seo/utils/validation/jsonld-validator.d.ts +2 -0
- package/dist/domains/seo/utils/validation/jsonld-validator.js +67 -0
- package/dist/domains/seo/utils/validation/language-code.d.ts +1 -0
- package/dist/domains/seo/utils/validation/language-code.js +2 -0
- package/dist/domains/seo/utils/validation/length-validator.d.ts +4 -0
- package/dist/domains/seo/utils/validation/length-validator.js +34 -0
- package/dist/domains/seo/utils/validation/seo-auditor.d.ts +3 -0
- package/dist/domains/seo/utils/validation/seo-auditor.js +120 -0
- package/dist/domains/seo/utils/validation/text-helpers.d.ts +1 -0
- package/dist/domains/seo/utils/validation/text-helpers.js +6 -0
- package/dist/domains/seo/utils/validation/url-validator.d.ts +2 -0
- package/dist/domains/seo/utils/validation/url-validator.js +20 -0
- package/dist/domains/seo/vite/index.d.ts +3 -7
- package/dist/domains/seo/vite/index.js +2 -6
- package/dist/domains/seo/vite/plugin.d.ts +1 -59
- package/dist/domains/seo/vite/plugin.js +26 -190
- package/dist/domains/seo/vite/presets.d.ts +8 -0
- package/dist/domains/seo/vite/presets.js +28 -0
- package/dist/domains/seo/vite/robots-generator.d.ts +6 -0
- package/dist/domains/seo/vite/robots-generator.js +33 -0
- package/dist/domains/seo/vite/sitemap-generator.d.ts +8 -0
- package/dist/domains/seo/vite/sitemap-generator.js +49 -0
- package/dist/domains/seo/vite/types.d.ts +20 -0
- package/dist/domains/seo/vite/types.js +1 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +4 -12
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateBreadcrumbSchema = (items, options) => createBuilder((input, ctx) => {
|
|
3
|
+
if (ctx.options.validate && input.length === 0) {
|
|
4
|
+
const message = "[SEO] Breadcrumb schema requires at least one item";
|
|
5
|
+
if (ctx.options.strict)
|
|
6
|
+
throw new Error(message);
|
|
7
|
+
console.warn(message);
|
|
8
|
+
}
|
|
9
|
+
ctx.set(withContext("BreadcrumbList"));
|
|
10
|
+
ctx.set({
|
|
11
|
+
itemListElement: input.map((item, index) => ({
|
|
12
|
+
"@type": "ListItem",
|
|
13
|
+
position: item.position ?? index + 1,
|
|
14
|
+
name: item.name,
|
|
15
|
+
item: item.item,
|
|
16
|
+
})),
|
|
17
|
+
});
|
|
18
|
+
})(items, options);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateCourseSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.required(input.description, "description");
|
|
5
|
+
ctx.required(input.providerName, "providerName");
|
|
6
|
+
ctx.set(withContext("Course"));
|
|
7
|
+
ctx.set({
|
|
8
|
+
name: input.name,
|
|
9
|
+
description: input.description,
|
|
10
|
+
provider: {
|
|
11
|
+
"@type": "Organization",
|
|
12
|
+
name: input.providerName,
|
|
13
|
+
url: input.providerUrl,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
if (input.image)
|
|
17
|
+
ctx.set({ image: input.image });
|
|
18
|
+
if (input.url)
|
|
19
|
+
ctx.set({ url: input.url });
|
|
20
|
+
if (input.courseCode)
|
|
21
|
+
ctx.set({ courseCode: input.courseCode });
|
|
22
|
+
if (input.educationalLevel)
|
|
23
|
+
ctx.set({ educationalLevel: input.educationalLevel });
|
|
24
|
+
if (input.inLanguage)
|
|
25
|
+
ctx.set({ inLanguage: input.inLanguage });
|
|
26
|
+
if (input.teaches)
|
|
27
|
+
ctx.set({ teaches: input.teaches });
|
|
28
|
+
if (input.price !== undefined && input.priceCurrency) {
|
|
29
|
+
ctx.set({
|
|
30
|
+
offers: {
|
|
31
|
+
"@type": "Offer",
|
|
32
|
+
price: input.price.toString(),
|
|
33
|
+
priceCurrency: input.priceCurrency,
|
|
34
|
+
availability: "https://schema.org/InStock",
|
|
35
|
+
url: input.url,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (input.aggregateRating) {
|
|
40
|
+
ctx.set({
|
|
41
|
+
aggregateRating: {
|
|
42
|
+
"@type": "AggregateRating",
|
|
43
|
+
ratingValue: input.aggregateRating.ratingValue,
|
|
44
|
+
reviewCount: input.aggregateRating.reviewCount,
|
|
45
|
+
bestRating: 5,
|
|
46
|
+
worstRating: 1,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (input.instances && input.instances.length > 0) {
|
|
51
|
+
const instances = input.instances.map((inst) => ({
|
|
52
|
+
"@type": "CourseInstance",
|
|
53
|
+
courseMode: inst.courseMode ?? "online",
|
|
54
|
+
courseWorkload: inst.courseWorkload,
|
|
55
|
+
inLanguage: inst.inLanguage ?? input.inLanguage,
|
|
56
|
+
startDate: inst.startDate,
|
|
57
|
+
endDate: inst.endDate,
|
|
58
|
+
...(inst.instructorName
|
|
59
|
+
? {
|
|
60
|
+
instructor: {
|
|
61
|
+
"@type": "Person",
|
|
62
|
+
name: inst.instructorName,
|
|
63
|
+
url: inst.instructorUrl,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
: {}),
|
|
67
|
+
}));
|
|
68
|
+
ctx.set({ hasCourseInstance: instances });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateFAQSchema = (faqs, options) => createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input, "faqs");
|
|
4
|
+
if (ctx.options.validate && input.length === 0) {
|
|
5
|
+
const message = "[SEO] FAQ schema requires at least one FAQ item";
|
|
6
|
+
if (ctx.options.strict)
|
|
7
|
+
throw new Error(message);
|
|
8
|
+
console.warn(message);
|
|
9
|
+
}
|
|
10
|
+
ctx.set(withContext("FAQPage"));
|
|
11
|
+
ctx.set({
|
|
12
|
+
mainEntity: input.map((faq) => ({
|
|
13
|
+
"@type": "Question",
|
|
14
|
+
name: faq.question,
|
|
15
|
+
acceptedAnswer: {
|
|
16
|
+
"@type": "Answer",
|
|
17
|
+
text: faq.answer,
|
|
18
|
+
},
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
21
|
+
})(faqs, options);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LocalBusinessJsonLd } from "../../../types/schema.js";
|
|
2
|
+
import type { LocalBusinessSchemaInput } from "../types.js";
|
|
3
|
+
export declare const generateLocalBusinessSchema: (input: LocalBusinessSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => LocalBusinessJsonLd;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateLocalBusinessSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.required(input.address, "address");
|
|
5
|
+
ctx.set(withContext(input.type ?? "LocalBusiness"));
|
|
6
|
+
ctx.set({
|
|
7
|
+
name: input.name,
|
|
8
|
+
description: input.description,
|
|
9
|
+
url: input.url,
|
|
10
|
+
logo: input.logo,
|
|
11
|
+
address: { "@type": "PostalAddress", ...input.address },
|
|
12
|
+
priceRange: input.priceRange,
|
|
13
|
+
});
|
|
14
|
+
if (input.geo) {
|
|
15
|
+
ctx.set({
|
|
16
|
+
geo: {
|
|
17
|
+
"@type": "GeoCoordinates",
|
|
18
|
+
latitude: input.geo.latitude,
|
|
19
|
+
longitude: input.geo.longitude,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (input.openingHours) {
|
|
24
|
+
ctx.set({
|
|
25
|
+
openingHoursSpecification: input.openingHours.map((oh) => ({
|
|
26
|
+
"@type": "OpeningHoursSpecification",
|
|
27
|
+
dayOfWeek: oh.dayOfWeek,
|
|
28
|
+
opens: oh.opens,
|
|
29
|
+
closes: oh.closes,
|
|
30
|
+
})),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (input.contactPoint) {
|
|
34
|
+
ctx.set({
|
|
35
|
+
contactPoint: input.contactPoint.map((cp) => ({
|
|
36
|
+
"@type": "ContactPoint",
|
|
37
|
+
telephone: cp.telephone,
|
|
38
|
+
contactType: cp.contactType,
|
|
39
|
+
email: cp.email,
|
|
40
|
+
})),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (input.sameAs)
|
|
44
|
+
ctx.set({ sameAs: input.sameAs });
|
|
45
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OrganizationJsonLd } from "../../../types/schema.js";
|
|
2
|
+
import type { OrganizationSchemaInput } from "../types.js";
|
|
3
|
+
export declare const generateOrganizationSchema: (input: OrganizationSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => OrganizationJsonLd;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateOrganizationSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.set(withContext("Organization"));
|
|
5
|
+
ctx.set({
|
|
6
|
+
name: input.name,
|
|
7
|
+
description: input.description,
|
|
8
|
+
url: input.url,
|
|
9
|
+
logo: input.logo,
|
|
10
|
+
sameAs: input.sameAs,
|
|
11
|
+
});
|
|
12
|
+
if (input.contactPoint) {
|
|
13
|
+
ctx.set({
|
|
14
|
+
contactPoint: input.contactPoint.map((cp) => ({
|
|
15
|
+
"@type": "ContactPoint",
|
|
16
|
+
telephone: cp.telephone,
|
|
17
|
+
contactType: cp.contactType,
|
|
18
|
+
email: cp.email,
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (input.address) {
|
|
23
|
+
ctx.set({ address: { "@type": "PostalAddress", ...input.address } });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generatePersonSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.set(withContext("Person"));
|
|
5
|
+
ctx.set({
|
|
6
|
+
name: input.name,
|
|
7
|
+
givenName: input.givenName,
|
|
8
|
+
familyName: input.familyName,
|
|
9
|
+
jobTitle: input.jobTitle,
|
|
10
|
+
description: input.description,
|
|
11
|
+
image: input.image,
|
|
12
|
+
url: input.url,
|
|
13
|
+
sameAs: input.sameAs,
|
|
14
|
+
email: input.email,
|
|
15
|
+
telephone: input.telephone,
|
|
16
|
+
});
|
|
17
|
+
if (input.worksFor) {
|
|
18
|
+
ctx.set({
|
|
19
|
+
worksFor: {
|
|
20
|
+
"@context": "https://schema.org",
|
|
21
|
+
"@type": "Organization",
|
|
22
|
+
name: input.worksFor.name,
|
|
23
|
+
url: input.worksFor.url,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProductJsonLd } from "../../../types/schema.js";
|
|
2
|
+
import type { ProductSchemaInput } from "../types.js";
|
|
3
|
+
export declare const generateProductSchema: (input: ProductSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => ProductJsonLd;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateProductSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.required(input.image, "image");
|
|
5
|
+
ctx.required(input.price, "price");
|
|
6
|
+
ctx.required(input.priceCurrency, "priceCurrency");
|
|
7
|
+
ctx.set(withContext("Product"));
|
|
8
|
+
ctx.set({
|
|
9
|
+
name: input.name,
|
|
10
|
+
description: input.description,
|
|
11
|
+
image: input.image,
|
|
12
|
+
offers: {
|
|
13
|
+
"@type": "Offer",
|
|
14
|
+
price: input.price.toString(),
|
|
15
|
+
priceCurrency: input.priceCurrency,
|
|
16
|
+
availability: input.availability
|
|
17
|
+
? `https://schema.org/${input.availability}`
|
|
18
|
+
: undefined,
|
|
19
|
+
url: input.url,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (input.brandName) {
|
|
23
|
+
ctx.set({ brand: { "@type": "Brand", name: input.brandName } });
|
|
24
|
+
}
|
|
25
|
+
if (input.sku)
|
|
26
|
+
ctx.set({ sku: input.sku });
|
|
27
|
+
if (input.gtin)
|
|
28
|
+
ctx.set({ gtin: input.gtin });
|
|
29
|
+
if (input.aggregateRating) {
|
|
30
|
+
ctx.set({
|
|
31
|
+
aggregateRating: {
|
|
32
|
+
"@type": "AggregateRating",
|
|
33
|
+
ratingValue: input.aggregateRating.ratingValue,
|
|
34
|
+
reviewCount: input.aggregateRating.reviewCount,
|
|
35
|
+
bestRating: 5,
|
|
36
|
+
worstRating: 1,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateVideoSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.required(input.thumbnailUrl, "thumbnailUrl");
|
|
5
|
+
ctx.required(input.uploadDate, "uploadDate");
|
|
6
|
+
ctx.set(withContext("VideoObject"));
|
|
7
|
+
ctx.set({
|
|
8
|
+
name: input.name,
|
|
9
|
+
description: input.description,
|
|
10
|
+
thumbnailUrl: input.thumbnailUrl,
|
|
11
|
+
uploadDate: input.uploadDate,
|
|
12
|
+
duration: input.duration,
|
|
13
|
+
});
|
|
14
|
+
if (input.viewCount) {
|
|
15
|
+
ctx.set({
|
|
16
|
+
interactionStatistic: {
|
|
17
|
+
"@type": "InteractionCounter",
|
|
18
|
+
interactionType: { "@type": "WatchAction" },
|
|
19
|
+
userInteractionCount: input.viewCount,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { WebSiteJsonLd } from "../../../types/schema.js";
|
|
2
|
+
import type { WebSiteSchemaInput } from "../types.js";
|
|
3
|
+
export declare const generateWebSiteSchema: (input: WebSiteSchemaInput, options?: import("../../../types/schema.js").SchemaGeneratorOptions) => WebSiteJsonLd;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createBuilder, withContext } from "../base.js";
|
|
2
|
+
export const generateWebSiteSchema = createBuilder((input, ctx) => {
|
|
3
|
+
ctx.required(input.name, "name");
|
|
4
|
+
ctx.required(input.url, "url");
|
|
5
|
+
ctx.set(withContext("WebSite"));
|
|
6
|
+
ctx.set({
|
|
7
|
+
name: input.name,
|
|
8
|
+
url: input.url,
|
|
9
|
+
description: input.description,
|
|
10
|
+
});
|
|
11
|
+
if (input.searchTarget) {
|
|
12
|
+
ctx.set({
|
|
13
|
+
potentialAction: {
|
|
14
|
+
"@type": "SearchAction",
|
|
15
|
+
target: input.searchTarget,
|
|
16
|
+
"query-input": input.searchQueryParam ?? "required name=search_term_string",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (input.publisher) {
|
|
21
|
+
ctx.set({
|
|
22
|
+
publisher: {
|
|
23
|
+
"@context": "https://schema.org",
|
|
24
|
+
"@type": "Organization",
|
|
25
|
+
name: input.publisher.name,
|
|
26
|
+
logo: input.publisher.logo,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
export { generateArticleSchema } from "./generators/article.js";
|
|
2
|
+
export { generateProductSchema } from "./generators/product.js";
|
|
3
|
+
export { generateOrganizationSchema } from "./generators/organization.js";
|
|
4
|
+
export { generateLocalBusinessSchema } from "./generators/local-business.js";
|
|
5
|
+
export { generateBreadcrumbSchema } from "./generators/breadcrumb.js";
|
|
6
|
+
export { generateFAQSchema } from "./generators/faq.js";
|
|
7
|
+
export { generateWebSiteSchema } from "./generators/website.js";
|
|
8
|
+
export { generatePersonSchema } from "./generators/person.js";
|
|
9
|
+
export { generateVideoSchema } from "./generators/video.js";
|
|
10
|
+
export { generateCourseSchema } from "./generators/course.js";
|
|
11
|
+
export { schemaFactory } from "./factory.js";
|
|
12
|
+
export type { SchemaKind } from "./factory.js";
|
|
13
|
+
export type { ArticleSchemaInput, ProductSchemaInput, OrganizationSchemaInput, LocalBusinessSchemaInput, FAQItemInput, WebSiteSchemaInput, PersonSchemaInput, VideoSchemaInput, CourseSchemaInput, CourseInstanceInput, ContactPointInput, PostalAddressInput, } from "./types.js";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
export { generateArticleSchema } from "./generators/article.js";
|
|
2
|
+
export { generateProductSchema } from "./generators/product.js";
|
|
3
|
+
export { generateOrganizationSchema } from "./generators/organization.js";
|
|
4
|
+
export { generateLocalBusinessSchema } from "./generators/local-business.js";
|
|
5
|
+
export { generateBreadcrumbSchema } from "./generators/breadcrumb.js";
|
|
6
|
+
export { generateFAQSchema } from "./generators/faq.js";
|
|
7
|
+
export { generateWebSiteSchema } from "./generators/website.js";
|
|
8
|
+
export { generatePersonSchema } from "./generators/person.js";
|
|
9
|
+
export { generateVideoSchema } from "./generators/video.js";
|
|
10
|
+
export { generateCourseSchema } from "./generators/course.js";
|
|
11
|
+
export { schemaFactory } from "./factory.js";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export interface ArticleSchemaInput {
|
|
2
|
+
headline: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
image: string | string[];
|
|
5
|
+
datePublished: string;
|
|
6
|
+
dateModified?: string;
|
|
7
|
+
authorName: string;
|
|
8
|
+
authorUrl?: string;
|
|
9
|
+
authorType?: "Person" | "Organization";
|
|
10
|
+
publisherName: string;
|
|
11
|
+
publisherLogo: string;
|
|
12
|
+
publisherUrl?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
articleSection?: string;
|
|
15
|
+
wordCount?: number;
|
|
16
|
+
keywords?: string | string[];
|
|
17
|
+
inLanguage?: string;
|
|
18
|
+
type?: "Article" | "NewsArticle" | "BlogPosting";
|
|
19
|
+
}
|
|
20
|
+
export interface ProductSchemaInput {
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
image: string | string[];
|
|
24
|
+
price: number;
|
|
25
|
+
priceCurrency: string;
|
|
26
|
+
availability?: "InStock" | "OutOfStock" | "PreOrder";
|
|
27
|
+
url?: string;
|
|
28
|
+
brandName?: string;
|
|
29
|
+
sku?: string;
|
|
30
|
+
gtin?: string;
|
|
31
|
+
aggregateRating?: {
|
|
32
|
+
ratingValue: number;
|
|
33
|
+
reviewCount: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface ContactPointInput {
|
|
37
|
+
telephone: string;
|
|
38
|
+
contactType: string;
|
|
39
|
+
email?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface PostalAddressInput {
|
|
42
|
+
streetAddress: string;
|
|
43
|
+
addressLocality: string;
|
|
44
|
+
addressRegion: string;
|
|
45
|
+
postalCode: string;
|
|
46
|
+
addressCountry: string;
|
|
47
|
+
}
|
|
48
|
+
export interface OrganizationSchemaInput {
|
|
49
|
+
name: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
url?: string;
|
|
52
|
+
logo?: string;
|
|
53
|
+
sameAs?: string[];
|
|
54
|
+
contactPoint?: ContactPointInput[];
|
|
55
|
+
address?: PostalAddressInput;
|
|
56
|
+
}
|
|
57
|
+
export interface LocalBusinessSchemaInput extends OrganizationSchemaInput {
|
|
58
|
+
address: PostalAddressInput;
|
|
59
|
+
geo?: {
|
|
60
|
+
latitude: number;
|
|
61
|
+
longitude: number;
|
|
62
|
+
};
|
|
63
|
+
openingHours?: Array<{
|
|
64
|
+
dayOfWeek: string | string[];
|
|
65
|
+
opens: string;
|
|
66
|
+
closes: string;
|
|
67
|
+
}>;
|
|
68
|
+
priceRange?: string;
|
|
69
|
+
type?: "LocalBusiness" | "Restaurant" | "Store" | "Dentist" | "Hospital";
|
|
70
|
+
}
|
|
71
|
+
export interface FAQItemInput {
|
|
72
|
+
question: string;
|
|
73
|
+
answer: string;
|
|
74
|
+
}
|
|
75
|
+
export interface WebSiteSchemaInput {
|
|
76
|
+
name: string;
|
|
77
|
+
url: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
searchTarget?: string;
|
|
80
|
+
searchQueryParam?: string;
|
|
81
|
+
publisher?: {
|
|
82
|
+
name: string;
|
|
83
|
+
logo?: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export interface PersonSchemaInput {
|
|
87
|
+
name: string;
|
|
88
|
+
givenName?: string;
|
|
89
|
+
familyName?: string;
|
|
90
|
+
jobTitle?: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
image?: string;
|
|
93
|
+
url?: string;
|
|
94
|
+
sameAs?: string[];
|
|
95
|
+
email?: string;
|
|
96
|
+
telephone?: string;
|
|
97
|
+
worksFor?: {
|
|
98
|
+
name: string;
|
|
99
|
+
url?: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export interface VideoSchemaInput {
|
|
103
|
+
name: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
thumbnailUrl: string;
|
|
106
|
+
uploadDate: string;
|
|
107
|
+
duration?: string;
|
|
108
|
+
embedUrl?: string;
|
|
109
|
+
viewCount?: number;
|
|
110
|
+
}
|
|
111
|
+
export interface CourseInstanceInput {
|
|
112
|
+
courseMode?: "online" | "onsite" | "blended" | string;
|
|
113
|
+
courseWorkload?: string;
|
|
114
|
+
instructorName?: string;
|
|
115
|
+
instructorUrl?: string;
|
|
116
|
+
inLanguage?: string;
|
|
117
|
+
startDate?: string;
|
|
118
|
+
endDate?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface CourseSchemaInput {
|
|
121
|
+
name: string;
|
|
122
|
+
description: string;
|
|
123
|
+
providerName: string;
|
|
124
|
+
providerUrl?: string;
|
|
125
|
+
image?: string | string[];
|
|
126
|
+
url?: string;
|
|
127
|
+
courseCode?: string;
|
|
128
|
+
educationalLevel?: string;
|
|
129
|
+
inLanguage?: string;
|
|
130
|
+
price?: number;
|
|
131
|
+
priceCurrency?: string;
|
|
132
|
+
teaches?: string | string[];
|
|
133
|
+
aggregateRating?: {
|
|
134
|
+
ratingValue: number;
|
|
135
|
+
reviewCount: number;
|
|
136
|
+
};
|
|
137
|
+
instances?: CourseInstanceInput[];
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isValidLanguageCode } from "./language-code.js";
|
|
2
|
+
import { validateUrl } from "./url-validator.js";
|
|
3
|
+
export const validateHreflangEntry = (entry) => {
|
|
4
|
+
if (!entry.lang)
|
|
5
|
+
return "Hreflang language code is required";
|
|
6
|
+
if (!isValidLanguageCode(entry.lang)) {
|
|
7
|
+
return `Invalid language code: ${entry.lang}`;
|
|
8
|
+
}
|
|
9
|
+
return validateUrl(entry.url, "Hreflang URL");
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateOpenGraphImage: (imageUrl: string, width?: number, height?: number, size?: number) => string | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OG_IMAGE_MAX_SIZE, OG_IMAGE_MIN_HEIGHT, OG_IMAGE_MIN_WIDTH, } from "../../core/constants.js";
|
|
2
|
+
import { isValidUrl } from "./url-validator.js";
|
|
3
|
+
export const validateOpenGraphImage = (imageUrl, width, height, size) => {
|
|
4
|
+
if (!imageUrl)
|
|
5
|
+
return "Open Graph image URL is required";
|
|
6
|
+
if (!isValidUrl(imageUrl))
|
|
7
|
+
return "Open Graph image URL must be valid";
|
|
8
|
+
if (width !== undefined && width < OG_IMAGE_MIN_WIDTH) {
|
|
9
|
+
return `Open Graph image width should be at least ${OG_IMAGE_MIN_WIDTH}px (current: ${width}px)`;
|
|
10
|
+
}
|
|
11
|
+
if (height !== undefined && height < OG_IMAGE_MIN_HEIGHT) {
|
|
12
|
+
return `Open Graph image height should be at least ${OG_IMAGE_MIN_HEIGHT}px (current: ${height}px)`;
|
|
13
|
+
}
|
|
14
|
+
if (size !== undefined && size > OG_IMAGE_MAX_SIZE) {
|
|
15
|
+
return `Open Graph image size should not exceed ${OG_IMAGE_MAX_SIZE / 1024 / 1024}MB`;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
export { isValidUrl, validateUrl } from "./url-validator.js";
|
|
2
|
+
export { isValidLanguageCode } from "./language-code.js";
|
|
3
|
+
export { validateTitleLength, validateDescriptionLength, truncateToTitle, truncateToDescription, } from "./length-validator.js";
|
|
4
|
+
export { validateOpenGraphImage } from "./image-validator.js";
|
|
5
|
+
export { validateHreflangEntry } from "./hreflang-validator.js";
|
|
6
|
+
export { validateJsonLd } from "./jsonld-validator.js";
|
|
7
|
+
export { validateSEO, auditSEO } from "./seo-auditor.js";
|
|
8
|
+
export { generateSlug } from "./text-helpers.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
export { isValidUrl, validateUrl } from "./url-validator.js";
|
|
2
|
+
export { isValidLanguageCode } from "./language-code.js";
|
|
3
|
+
export { validateTitleLength, validateDescriptionLength, truncateToTitle, truncateToDescription, } from "./length-validator.js";
|
|
4
|
+
export { validateOpenGraphImage } from "./image-validator.js";
|
|
5
|
+
export { validateHreflangEntry } from "./hreflang-validator.js";
|
|
6
|
+
export { validateJsonLd } from "./jsonld-validator.js";
|
|
7
|
+
export { validateSEO, auditSEO } from "./seo-auditor.js";
|
|
8
|
+
export { generateSlug } from "./text-helpers.js";
|