-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.ts
41 lines (38 loc) · 909 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { structuredDataTest } = require("structured-data-testing-tool");
const {
Google,
Twitter,
Facebook,
} = require("structured-data-testing-tool/presets");
export interface StructuredDataParam {
url: string;
schemas?: [string];
presets?: ["Google", "Twitter", "Facebook", "SocialMedia"];
}
export interface StructuredDataResult {
failed: Array<any>;
groups: Array<any>;
optional: Array<any>;
options: Array<any>;
passed: Array<any>;
schemas: Array<any>;
skipped: Array<any>;
structuredData: Array<any>;
tests: Array<any>;
warnings: Array<any>;
}
export const structuredData = async ({
url,
schemas,
presets,
}: StructuredDataParam): Promise<StructuredDataResult> => {
const result = await structuredDataTest(url, {
schemas: schemas,
presets: presets,
auto: false,
}).catch((err) => {
console.warn(err);
return {};
});
return result;
};