@react-pakistan/util-functions 1.22.11 → 1.22.13
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/general/generate-blog-schema.d.ts +34 -0
- package/general/generate-blog-schema.js +22 -0
- package/general/generate-breadcrumb-schema.d.ts +18 -0
- package/general/generate-breadcrumb-schema.js +35 -0
- package/general/generate-faq-schema.d.ts +25 -0
- package/general/generate-faq-schema.js +22 -0
- package/general/generate-organization-schema.d.ts +44 -0
- package/general/generate-organization-schema.js +27 -0
- package/general/index.d.ts +2 -0
- package/general/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A util function to create Rich Schema for FAQ
|
|
3
|
+
*
|
|
4
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
5
|
+
* @author Taimoor Khan
|
|
6
|
+
* @remarks AppCorp
|
|
7
|
+
*/
|
|
8
|
+
/** End file docs */
|
|
9
|
+
interface Blog {
|
|
10
|
+
authorImage: string;
|
|
11
|
+
authorName: string;
|
|
12
|
+
banner: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
excerpt: string;
|
|
15
|
+
title: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
url: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const generateBlogSchema: ({ authorImage, authorName, banner, createdAt, excerpt, title, updatedAt, url, }: Blog) => {
|
|
20
|
+
"@context": string;
|
|
21
|
+
"@type": string;
|
|
22
|
+
headline: string;
|
|
23
|
+
dateModified: string;
|
|
24
|
+
datePublished: string;
|
|
25
|
+
description: string;
|
|
26
|
+
image: string;
|
|
27
|
+
url: string;
|
|
28
|
+
author: {
|
|
29
|
+
"@type": string;
|
|
30
|
+
name: string;
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.generateBlogSchema = void 0;
|
|
5
|
+
const generateBlogSchema = ({ authorImage, authorName, banner, createdAt, excerpt, title, updatedAt, url, }) => {
|
|
6
|
+
return {
|
|
7
|
+
"@context": "https://schema.org",
|
|
8
|
+
"@type": "BlogPosting",
|
|
9
|
+
"headline": `${title}`,
|
|
10
|
+
"dateModified": `${updatedAt}`,
|
|
11
|
+
"datePublished": `${createdAt}`,
|
|
12
|
+
"description": `${excerpt}`,
|
|
13
|
+
"image": `${banner}`,
|
|
14
|
+
"url": `${url}`,
|
|
15
|
+
"author": {
|
|
16
|
+
"@type": "Person",
|
|
17
|
+
"name": `${authorName}`,
|
|
18
|
+
"url": `${authorImage}`,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.generateBlogSchema = generateBlogSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A util function to create Rich Schema for Breadcrumbs
|
|
3
|
+
*
|
|
4
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
5
|
+
* @author Taimoor Khan
|
|
6
|
+
* @remarks AppCorp
|
|
7
|
+
*/
|
|
8
|
+
/** End file docs */
|
|
9
|
+
export declare const generateBreadcrumbSchema: (arr: Array<string>, baseUrl: string) => {
|
|
10
|
+
"@context": string;
|
|
11
|
+
"@type": string;
|
|
12
|
+
itemListElement: {
|
|
13
|
+
"@type": string;
|
|
14
|
+
position: number;
|
|
15
|
+
name: string;
|
|
16
|
+
item: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.generateBreadcrumbSchema = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* A util function to create Rich Schema for Breadcrumbs
|
|
7
|
+
*
|
|
8
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
9
|
+
* @author Taimoor Khan
|
|
10
|
+
* @remarks AppCorp
|
|
11
|
+
*/
|
|
12
|
+
/** End file docs */
|
|
13
|
+
const generateBreadcrumbSchema = (arr, baseUrl) => {
|
|
14
|
+
const items = arr.map((text, index) => {
|
|
15
|
+
let urlItem = '';
|
|
16
|
+
if (text === 'Home') {
|
|
17
|
+
urlItem = baseUrl;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
urlItem = `${baseUrl}/${text.toLowerCase()}`;
|
|
21
|
+
}
|
|
22
|
+
return ({
|
|
23
|
+
"@type": "ListItem",
|
|
24
|
+
"position": index + 1,
|
|
25
|
+
"name": text,
|
|
26
|
+
"item": urlItem,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
"@context": "https://schema.org",
|
|
31
|
+
"@type": "BreadcrumbList",
|
|
32
|
+
"itemListElement": items,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.generateBreadcrumbSchema = generateBreadcrumbSchema;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A util function to create Rich Schema for FAQ
|
|
3
|
+
*
|
|
4
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
5
|
+
* @author Taimoor Khan
|
|
6
|
+
* @remarks AppCorp
|
|
7
|
+
*/
|
|
8
|
+
/** End file docs */
|
|
9
|
+
interface FAQ {
|
|
10
|
+
answer: string;
|
|
11
|
+
question: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const generateFAQSchema: (arr: Array<FAQ>) => {
|
|
14
|
+
"@context": string;
|
|
15
|
+
"@type": string;
|
|
16
|
+
mainEntity: {
|
|
17
|
+
"@type": string;
|
|
18
|
+
name: string;
|
|
19
|
+
acceptedAnswer: {
|
|
20
|
+
"@type": string;
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.generateFAQSchema = void 0;
|
|
5
|
+
const generateFAQSchema = (arr) => {
|
|
6
|
+
const items = arr.map(({ answer, question }) => {
|
|
7
|
+
return ({
|
|
8
|
+
"@type": "Question",
|
|
9
|
+
"name": question,
|
|
10
|
+
"acceptedAnswer": {
|
|
11
|
+
"@type": "Answer",
|
|
12
|
+
"text": `<p>${answer}</p>`
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
"@context": "https://schema.org",
|
|
18
|
+
"@type": "FAQPage",
|
|
19
|
+
"mainEntity": items,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.generateFAQSchema = generateFAQSchema;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A util function to create Rich Schema for Organization
|
|
3
|
+
*
|
|
4
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
5
|
+
* @author Taimoor Khan
|
|
6
|
+
* @remarks AppCorp
|
|
7
|
+
*/
|
|
8
|
+
/** End file docs */
|
|
9
|
+
interface Organization {
|
|
10
|
+
addressCountry: string;
|
|
11
|
+
addressLocality: string;
|
|
12
|
+
addressRegion: string;
|
|
13
|
+
appName: string;
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
description: string;
|
|
16
|
+
email: string;
|
|
17
|
+
image: string;
|
|
18
|
+
logo: string;
|
|
19
|
+
postalCode: string;
|
|
20
|
+
sameAsArr: Array<string>;
|
|
21
|
+
streetAddress: string;
|
|
22
|
+
telephone: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const generateOrganizationSchema: ({ addressCountry, addressLocality, addressRegion, appName, baseUrl, description, email, image, logo, postalCode, sameAsArr, streetAddress, telephone, }: Organization) => {
|
|
25
|
+
"@context": string;
|
|
26
|
+
"@type": string;
|
|
27
|
+
image: string;
|
|
28
|
+
url: string;
|
|
29
|
+
sameAs: string[];
|
|
30
|
+
logo: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
email: string;
|
|
34
|
+
telephone: string;
|
|
35
|
+
address: {
|
|
36
|
+
"@type": string;
|
|
37
|
+
streetAddress: string;
|
|
38
|
+
addressLocality: string;
|
|
39
|
+
addressCountry: string;
|
|
40
|
+
addressRegion: string;
|
|
41
|
+
postalCode: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.generateOrganizationSchema = void 0;
|
|
5
|
+
const generateOrganizationSchema = ({ addressCountry, addressLocality, addressRegion, appName, baseUrl, description, email, image, logo, postalCode, sameAsArr, streetAddress, telephone, }) => {
|
|
6
|
+
return {
|
|
7
|
+
"@context": "https://schema.org",
|
|
8
|
+
"@type": "Organization",
|
|
9
|
+
"image": `${image}`,
|
|
10
|
+
"url": `${baseUrl}`,
|
|
11
|
+
"sameAs": sameAsArr,
|
|
12
|
+
"logo": `${logo}`,
|
|
13
|
+
"name": `${appName}`,
|
|
14
|
+
"description": `${description}`,
|
|
15
|
+
"email": `${email}`,
|
|
16
|
+
"telephone": `${telephone}`,
|
|
17
|
+
"address": {
|
|
18
|
+
"@type": "PostalAddress",
|
|
19
|
+
"streetAddress": `${streetAddress}`,
|
|
20
|
+
"addressLocality": `${addressLocality}`,
|
|
21
|
+
"addressCountry": `${addressCountry}`,
|
|
22
|
+
"addressRegion": `${addressRegion}`,
|
|
23
|
+
"postalCode": `${postalCode}`,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
exports.generateOrganizationSchema = generateOrganizationSchema;
|
package/general/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from './check-even-odd-length';
|
|
|
5
5
|
export * from './countries';
|
|
6
6
|
export * from './currencies';
|
|
7
7
|
export * from './format-date';
|
|
8
|
+
export * from './generate-breadcrumb-schema';
|
|
9
|
+
export * from './generate-faq-schema';
|
|
8
10
|
export * from './generate-grid';
|
|
9
11
|
export * from './get-day-name';
|
|
10
12
|
export * from './get-href';
|
package/general/index.js
CHANGED
|
@@ -22,6 +22,8 @@ __exportStar(require("./check-even-odd-length"), exports);
|
|
|
22
22
|
__exportStar(require("./countries"), exports);
|
|
23
23
|
__exportStar(require("./currencies"), exports);
|
|
24
24
|
__exportStar(require("./format-date"), exports);
|
|
25
|
+
__exportStar(require("./generate-breadcrumb-schema"), exports);
|
|
26
|
+
__exportStar(require("./generate-faq-schema"), exports);
|
|
25
27
|
__exportStar(require("./generate-grid"), exports);
|
|
26
28
|
__exportStar(require("./get-day-name"), exports);
|
|
27
29
|
__exportStar(require("./get-href"), exports);
|