@content-island/gatsby-source-plugin 0.1.4 → 0.2.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.
@@ -16,16 +16,15 @@ let CONTENT_TYPES = [];
16
16
  // Fetch all content types from Content Island
17
17
  const getContentTypes = (client) => __awaiter(void 0, void 0, void 0, function* () {
18
18
  if (CONTENT_TYPES.length === 0) {
19
- const projects = yield client.get(api_client_1.API_URLS.projectList());
20
- CONTENT_TYPES = projects.flatMap(p => p.entities);
19
+ const project = yield client.get(api_client_1.API_URLS.project);
20
+ CONTENT_TYPES = project.entities;
21
21
  }
22
22
  return CONTENT_TYPES;
23
23
  });
24
24
  let CONTENT_LIST = [];
25
25
  const getContentList = (pluginOptions) => __awaiter(void 0, void 0, void 0, function* () {
26
26
  if (CONTENT_LIST.length === 0) {
27
- const { accessToken } = pluginOptions;
28
- const client = (0, api_client_1.createContentIslandClient)({ accessToken });
27
+ const client = (0, api_client_1.createContentIslandClient)(pluginOptions);
29
28
  const contentTypes = yield getContentTypes(client);
30
29
  for (const contentType of contentTypes) {
31
30
  const contents = yield client.get(api_client_1.API_URLS.contentList({ filterList: [`contentType=${contentType.name}`] }));
package/dist/mappers.js CHANGED
@@ -29,7 +29,7 @@ const mapContentFromApiToVm = (content, isLocalized, language) => {
29
29
  const fields = isLocalized ? content.fields.filter(field => field.language === language) : content.fields;
30
30
  return {
31
31
  gatsbyNodeType,
32
- gatsbyNode: Object.assign({ _id: content.id, _isContentIslandNode: true, _mediaFields: mapToPreprocessedFieldList(fields, gatsbyNodeType, 'media'), _markdownFields: mapToPreprocessedFieldList(fields, gatsbyNodeType, 'long-text'), _lastModified: content.lastModified, _isLocalized: isLocalized, _language: language }, mapFieldListFromApiToVm(fields)),
32
+ gatsbyNode: Object.assign({ _id: content.id, _isContentIslandNode: true, _mediaFields: mapToPreprocessedFieldList(fields, gatsbyNodeType, 'media'), _markdownFields: mapToPreprocessedFieldList(fields, gatsbyNodeType, 'long-text'), _lastUpdate: content.lastUpdate, _isLocalized: isLocalized, _language: language }, mapFieldListFromApiToVm(fields)),
33
33
  };
34
34
  };
35
35
  const mapLocalizedContentFromApiToVm = (content) => {
@@ -11,7 +11,7 @@ export interface ContentIslandNode {
11
11
  _isContentIslandNode: boolean;
12
12
  _mediaFields: PreprocessedField<Resource>[];
13
13
  _markdownFields: PreprocessedField<string>[];
14
- _lastModified: Date;
14
+ _lastUpdate: Date;
15
15
  _isLocalized: boolean;
16
16
  _language?: string;
17
17
  [key: string]: any;
@@ -1,6 +1,7 @@
1
1
  import type { PluginOptions as GatsbyDefaultPluginOptions, IPluginRefOptions } from 'gatsby';
2
2
  interface PluginOptionsKeys {
3
3
  accessToken: string;
4
+ baseUrl?: string;
4
5
  }
5
6
  /**
6
7
  * Gatsby expects the plugin options to be of type "PluginOptions" for gatsby-node APIs (e.g. sourceNodes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@content-island/gatsby-source-plugin",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Content Island - B2B Gatsby Source Plugin",
5
5
  "private": false,
6
6
  "author": "Lemoncode",
@@ -27,7 +27,7 @@
27
27
  "build": "tsc"
28
28
  },
29
29
  "dependencies": {
30
- "@content-island/api-client": "*"
30
+ "@content-island/api-client": "^0.2.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "gatsby": "^5.12.4",