@ndlib/component-library 0.0.56 → 0.0.60
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/components/composites/StructuredData/StructuredData.test.js +34 -4
- package/dist/components/composites/StructuredData/StructuredDataDisplay/index.js +31 -1
- package/dist/components/composites/StructuredData/index.d.ts +27 -3
- package/dist/components/composites/StructuredData/index.js +28 -30
- package/dist/components/composites/StructuredData/siteMetadata.d.ts +0 -26
- package/dist/components/composites/StructuredData/siteMetadata.js +0 -30
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,15 +1,45 @@
|
|
|
1
1
|
import { getStructuredDataSchemas } from './';
|
|
2
2
|
describe('getStructuredDataSchemas', () => {
|
|
3
3
|
it('should generate structured data schemas with default data', () => {
|
|
4
|
-
const schemas = getStructuredDataSchemas({
|
|
5
|
-
expect(schemas).
|
|
4
|
+
const schemas = getStructuredDataSchemas({});
|
|
5
|
+
expect(schemas[0]).toContain('Hesburgh Component Library');
|
|
6
|
+
expect(schemas).toHaveLength(1);
|
|
7
|
+
console.log(schemas);
|
|
6
8
|
});
|
|
7
9
|
it('should generate structured data schemas with custom data', () => {
|
|
8
10
|
const customData = {
|
|
9
11
|
title: 'Custom Title',
|
|
10
12
|
description: 'Custom Description',
|
|
11
|
-
events: [
|
|
12
|
-
|
|
13
|
+
events: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Archival Research Lab II: Inside the Archive',
|
|
16
|
+
startDate: '2021-10-13T14:00:00.000Z',
|
|
17
|
+
endDate: '2021-10-13T15:15:00.000Z',
|
|
18
|
+
slug: 'archival-research-lab-2-inside-the-archive-2021-10-13',
|
|
19
|
+
shortDescription: 'This two-session workshop provides an introduction to advanced archival research.',
|
|
20
|
+
representationalImage: {
|
|
21
|
+
url: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.amazonaws.com/events_hl_workshop_1403f3079f.jpg?AWSAccessKeyId=AKIATLJDMPVTNRHRTTAL&Expires=1698764137&Signature=oDIw1iGhnDLsDcvvlSHOn5KSRrI%3D',
|
|
22
|
+
},
|
|
23
|
+
location: {
|
|
24
|
+
address: '103 Hesburgh Library, Rare Books & Special Collections',
|
|
25
|
+
},
|
|
26
|
+
locationText: {
|
|
27
|
+
name: 'Hesburgh Concourse',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
news: [
|
|
32
|
+
{
|
|
33
|
+
title: 'Preservation Week 2023: Tips from the Hesburgh Libraries Preservation Team',
|
|
34
|
+
author: 'Hesburgh Libraries Analog Preservation and Conservation Unit',
|
|
35
|
+
shortDescription: 'Hesburgh Libraries preservation experts offer some helpful tips on safely preserving your valued collections.',
|
|
36
|
+
image: {
|
|
37
|
+
url: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.amazonaws.com/Preservation_Week_Rep_f85c55dd55.png?AWSAccessKeyId=AKIATLJDMPVTNRHRTTAL&Expires=1698764137&Signature=9jjAAAXWqJ7kBK4Tn5G7jvGK%2BfA%3D',
|
|
38
|
+
},
|
|
39
|
+
slug: 'preservation-week-2023',
|
|
40
|
+
publishedDate: '2023-04-30T04:00:00.000Z',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
13
43
|
};
|
|
14
44
|
const schemas = getStructuredDataSchemas(customData);
|
|
15
45
|
expect(schemas).toHaveLength(3);
|
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { getStructuredDataSchemas } from '../index';
|
|
3
3
|
export const StructuredDataDisplay = () => {
|
|
4
|
-
const
|
|
4
|
+
const events = [
|
|
5
|
+
{
|
|
6
|
+
name: 'Archival Research Lab II: Inside the Archive',
|
|
7
|
+
startDate: '2021-10-13T14:00:00.000Z',
|
|
8
|
+
endDate: '2021-10-13T15:15:00.000Z',
|
|
9
|
+
slug: 'archival-research-lab-2-inside-the-archive-2021-10-13',
|
|
10
|
+
shortDescription: 'This two-session workshop provides an introduction to advanced archival research.',
|
|
11
|
+
representationalImage: {
|
|
12
|
+
url: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.amazonaws.com/events_hl_workshop_1403f3079f.jpg?AWSAccessKeyId=AKIATLJDMPVTNRHRTTAL&Expires=1698764137&Signature=oDIw1iGhnDLsDcvvlSHOn5KSRrI%3D',
|
|
13
|
+
},
|
|
14
|
+
location: {
|
|
15
|
+
address: '103 Hesburgh Library, Rare Books & Special Collections',
|
|
16
|
+
},
|
|
17
|
+
locationText: {
|
|
18
|
+
name: 'Hesburgh Concourse',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
const news = [
|
|
23
|
+
{
|
|
24
|
+
title: 'Preservation Week 2023: Tips from the Hesburgh Libraries Preservation Team',
|
|
25
|
+
author: 'Hesburgh Libraries Analog Preservation and Conservation Unit',
|
|
26
|
+
shortDescription: 'Hesburgh Libraries preservation experts offer some helpful tips on safely preserving your valued collections.',
|
|
27
|
+
image: {
|
|
28
|
+
url: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.amazonaws.com/Preservation_Week_Rep_f85c55dd55.png?AWSAccessKeyId=AKIATLJDMPVTNRHRTTAL&Expires=1698764137&Signature=9jjAAAXWqJ7kBK4Tn5G7jvGK%2BfA%3D',
|
|
29
|
+
},
|
|
30
|
+
slug: 'preservation-week-2023',
|
|
31
|
+
publishedDate: '2023-04-30T04:00:00.000Z',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
const schemas = getStructuredDataSchemas({ events: events, news: news });
|
|
5
35
|
return (_jsx(_Fragment, { children: schemas.map((schema, index) => (_jsxs("pre", { children: [_jsx("code", { children: schema }), _jsx("br", {})] }, index))) }));
|
|
6
36
|
};
|
|
7
37
|
export default StructuredDataDisplay;
|
|
@@ -6,9 +6,33 @@ export type StructuredDataProps = {
|
|
|
6
6
|
nofollow?: string;
|
|
7
7
|
noindex?: string;
|
|
8
8
|
image?: string;
|
|
9
|
-
events?:
|
|
10
|
-
|
|
9
|
+
events?: {
|
|
10
|
+
name: string;
|
|
11
|
+
startDate: string;
|
|
12
|
+
endDate: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
shortDescription: string;
|
|
15
|
+
representationalImage: {
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
18
|
+
location: {
|
|
19
|
+
address: string;
|
|
20
|
+
};
|
|
21
|
+
locationText: {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
}[];
|
|
25
|
+
news?: {
|
|
26
|
+
title: string;
|
|
27
|
+
author: string;
|
|
28
|
+
shortDescription: string;
|
|
29
|
+
image: {
|
|
30
|
+
url: string;
|
|
31
|
+
};
|
|
32
|
+
slug: string;
|
|
33
|
+
publishedDate: string;
|
|
34
|
+
}[];
|
|
11
35
|
};
|
|
12
|
-
export declare const getStructuredDataSchemas: ({ title, description, nofollow, noindex, image, }: StructuredDataProps) => string[];
|
|
36
|
+
export declare const getStructuredDataSchemas: ({ title, description, nofollow, noindex, image, events, news, }: StructuredDataProps) => string[];
|
|
13
37
|
export declare const StructuredData: React.FC<StructuredDataProps>;
|
|
14
38
|
export default StructuredData;
|
|
@@ -3,8 +3,8 @@ import { siteMetadata } from './siteMetadata';
|
|
|
3
3
|
import { stringifyWebpageSchema } from './sdWebsite';
|
|
4
4
|
import { stringifyEventSchema } from './sdEvent';
|
|
5
5
|
import { stringifyNewsSchema } from './sdNews';
|
|
6
|
-
export const getStructuredDataSchemas = ({ title, description, nofollow, noindex, image, }) => {
|
|
7
|
-
const { title: defaultTitle, description: defaultDescription, image: defaultImage, siteUrl, nofollow: defaultNofollow, noindex: defaultNoindex,
|
|
6
|
+
export const getStructuredDataSchemas = ({ title, description, nofollow, noindex, image, events, news, }) => {
|
|
7
|
+
const { title: defaultTitle, description: defaultDescription, image: defaultImage, siteUrl, nofollow: defaultNofollow, noindex: defaultNoindex, } = siteMetadata();
|
|
8
8
|
const metadata = {
|
|
9
9
|
title: title || defaultTitle,
|
|
10
10
|
description: description || defaultDescription,
|
|
@@ -13,6 +13,8 @@ export const getStructuredDataSchemas = ({ title, description, nofollow, noindex
|
|
|
13
13
|
image: image || defaultImage,
|
|
14
14
|
url: `${siteUrl}${location.pathname || ''}`,
|
|
15
15
|
lang: 'en',
|
|
16
|
+
events: events,
|
|
17
|
+
news: news,
|
|
16
18
|
};
|
|
17
19
|
const schemas = [];
|
|
18
20
|
if (location.pathname !== '') {
|
|
@@ -22,34 +24,30 @@ export const getStructuredDataSchemas = ({ title, description, nofollow, noindex
|
|
|
22
24
|
url: metadata.url,
|
|
23
25
|
lang: metadata.lang,
|
|
24
26
|
}));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
siteUrl: siteUrl,
|
|
50
|
-
}));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
27
|
+
events === null || events === void 0 ? void 0 : events.map((event) => {
|
|
28
|
+
schemas.push(stringifyEventSchema({
|
|
29
|
+
title: event.name,
|
|
30
|
+
description: event.shortDescription,
|
|
31
|
+
image: event.representationalImage.url,
|
|
32
|
+
url: event.slug,
|
|
33
|
+
startDate: event.startDate,
|
|
34
|
+
endDate: event.endDate,
|
|
35
|
+
eventLocation: event.location.address,
|
|
36
|
+
eventLocationName: event.locationText.name,
|
|
37
|
+
siteUrl: siteUrl,
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
news === null || news === void 0 ? void 0 : news.map((article) => {
|
|
41
|
+
schemas.push(stringifyNewsSchema({
|
|
42
|
+
title: article.title,
|
|
43
|
+
abstract: article.shortDescription,
|
|
44
|
+
author: article.author,
|
|
45
|
+
image: article.image.url,
|
|
46
|
+
url: article.slug,
|
|
47
|
+
publishedDate: article.publishedDate,
|
|
48
|
+
siteUrl: siteUrl,
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
53
51
|
}
|
|
54
52
|
return schemas;
|
|
55
53
|
};
|
|
@@ -6,30 +6,4 @@ export declare const siteMetadata: () => {
|
|
|
6
6
|
siteUrl: string;
|
|
7
7
|
nofollow: boolean;
|
|
8
8
|
noindex: boolean;
|
|
9
|
-
events: {
|
|
10
|
-
name: string;
|
|
11
|
-
startDate: string;
|
|
12
|
-
endDate: string;
|
|
13
|
-
slug: string;
|
|
14
|
-
shortDescription: string;
|
|
15
|
-
representationalImage: {
|
|
16
|
-
url: string;
|
|
17
|
-
};
|
|
18
|
-
location: {
|
|
19
|
-
address: string;
|
|
20
|
-
};
|
|
21
|
-
locationText: {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
}[];
|
|
25
|
-
news: {
|
|
26
|
-
title: string;
|
|
27
|
-
author: string;
|
|
28
|
-
shortDescription: string;
|
|
29
|
-
image: {
|
|
30
|
-
url: string;
|
|
31
|
-
};
|
|
32
|
-
slug: string;
|
|
33
|
-
publishedDate: string;
|
|
34
|
-
}[];
|
|
35
9
|
};
|
|
@@ -7,36 +7,6 @@ export const siteMetadata = () => {
|
|
|
7
7
|
siteUrl: 'https://www.library.nd.edu',
|
|
8
8
|
nofollow: false,
|
|
9
9
|
noindex: false,
|
|
10
|
-
events: [
|
|
11
|
-
{
|
|
12
|
-
name: 'Archival Research Lab II: Inside the Archive',
|
|
13
|
-
startDate: '2021-10-13T14:00:00.000Z',
|
|
14
|
-
endDate: '2021-10-13T15:15:00.000Z',
|
|
15
|
-
slug: 'archival-research-lab-2-inside-the-archive-2021-10-13',
|
|
16
|
-
shortDescription: 'This two-session workshop provides an introduction to advanced archival research.',
|
|
17
|
-
representationalImage: {
|
|
18
|
-
url: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.amazonaws.com/events_hl_workshop_1403f3079f.jpg?AWSAccessKeyId=AKIATLJDMPVTNRHRTTAL&Expires=1698764137&Signature=oDIw1iGhnDLsDcvvlSHOn5KSRrI%3D',
|
|
19
|
-
},
|
|
20
|
-
location: {
|
|
21
|
-
address: '103 Hesburgh Library, Rare Books & Special Collections',
|
|
22
|
-
},
|
|
23
|
-
locationText: {
|
|
24
|
-
name: 'Hesburgh Concourse',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
news: [
|
|
29
|
-
{
|
|
30
|
-
title: 'Preservation Week 2023: Tips from the Hesburgh Libraries Preservation Team',
|
|
31
|
-
author: 'Hesburgh Libraries Analog Preservation and Conservation Unit',
|
|
32
|
-
shortDescription: 'Hesburgh Libraries preservation experts offer some helpful tips on safely preserving your valued collections.',
|
|
33
|
-
image: {
|
|
34
|
-
url: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.amazonaws.com/Preservation_Week_Rep_f85c55dd55.png?AWSAccessKeyId=AKIATLJDMPVTNRHRTTAL&Expires=1698764137&Signature=9jjAAAXWqJ7kBK4Tn5G7jvGK%2BfA%3D',
|
|
35
|
-
},
|
|
36
|
-
slug: 'preservation-week-2023',
|
|
37
|
-
publishedDate: '2023-04-30T04:00:00.000Z',
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
10
|
};
|
|
41
11
|
return data;
|
|
42
12
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export { DropdownLinks } from './components/composites/DropdownLinks';
|
|
|
39
39
|
export { Modal } from './components/composites/Modal';
|
|
40
40
|
export { DragDropList, DragHandle } from './components/composites/DragDropList';
|
|
41
41
|
export { Seo } from './components/composites/Seo';
|
|
42
|
+
export { StructuredData } from './components/composites/StructuredData';
|
|
42
43
|
export { UiProvider } from './components/providers/ui';
|
|
43
44
|
export { MenuProvider, useMenu } from './components/providers/menu';
|
|
44
45
|
export { SnackBarProvider, useSnackBar } from './components/providers/snackBar';
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ export { DropdownLinks } from './components/composites/DropdownLinks';
|
|
|
38
38
|
export { Modal } from './components/composites/Modal';
|
|
39
39
|
export { DragDropList, DragHandle } from './components/composites/DragDropList';
|
|
40
40
|
export { Seo } from './components/composites/Seo';
|
|
41
|
+
export { StructuredData } from './components/composites/StructuredData';
|
|
41
42
|
export { UiProvider } from './components/providers/ui';
|
|
42
43
|
export { MenuProvider, useMenu } from './components/providers/menu';
|
|
43
44
|
export { SnackBarProvider, useSnackBar } from './components/providers/snackBar';
|