Skip to content

Commit

Permalink
Merge pull request #176 from schabibi1/feature/remove-axios
Browse files Browse the repository at this point in the history
feat: bump major version

BREAKING CHANGE: remove axios
  • Loading branch information
schabibi1 authored Jan 18, 2023
2 parents e587e80 + f2dc267 commit 35d76e7
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "16.13.2"
node-version: "18.0.0"
cache: "npm"
- name: Install dependencies
run: npm ci
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ npm install gatsby-source-storyblok
// yarn add gatsby-source-storyblok
```

#### Compatibility

| Version to install | Support |
| ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| Latest `gatsby-source-storyblok` | Modern browsers + Node 16+. [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) is implemented. |
| [Version 4](https://github.com/storyblok/gatsby-source-storyblok/tree/v4.2.1) `gatsby-source-storyblok@4` | Node 14 and lower Node with no Fetch API support

### Initialization

Register the plugin on your application and add the [access token](https://www.storyblok.com/docs/api/content-delivery#topics/authentication?utm_source=github.com&utm_medium=readme&utm_campaign=gatsby-source-storyblok) of your Storyblok space. You can also add the `apiPlugin` in case that you want to use the Storyblok API Client: For Spaces created under US region, you should pass the region like { apiOptions: { region: 'us' } }. If your space is under EU, no further configuration is required.
Expand Down
1 change: 1 addition & 0 deletions lib/__tests__/sync.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require("isomorphic-fetch")
const StoryblokClient = require('storyblok-js-client')
const Sync = require('../src/sync')

Expand Down
9 changes: 6 additions & 3 deletions lib/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const StoryblokClient = require('storyblok-js-client');
const { storyblokInit } = require('@storyblok/react');
require("isomorphic-fetch")
const { storyblokInit, apiPlugin, useStoryblokApi } = require('@storyblok/react');
const Sync = require('./src/sync');
const getStoryParams = require('./src/getStoryParams');
const stringify = require('json-stringify-safe');
const { createRemoteFileNode } = require(`gatsby-source-filesystem`);

exports.sourceNodes = async function ({ actions }, options) {
const { createNode, setPluginStatus } = actions;
const client = new StoryblokClient(options);
const { plugins, ...apiOptions } = options
storyblokInit({ use: [apiPlugin], apiOptions })

const client = useStoryblokApi()

Sync.init({
createNode,
Expand Down
1 change: 0 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export {
useStoryblokApi,
getStoryblokApi,
renderRichText,
RichTextSchema
} from "@storyblok/react";

import type {
Expand Down
8 changes: 4 additions & 4 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"prepublishOnly": "npm run build && cp ../README.md ./"
},
"dependencies": {
"@storyblok/react": "^1.3.0",
"@storyblok/react": "^2.0.4",
"gatsby-source-filesystem": "^4.0.0",
"json-stringify-safe": "^5.0.1",
"storyblok-js-client": "^4.5.2"
"isomorphic-fetch": "^3.0.0",
"json-stringify-safe": "^5.0.1"
},
"devDependencies": {
"@babel/core": "^7.18.0",
Expand Down Expand Up @@ -92,4 +92,4 @@
"gatsby-plugin",
"gatsby-source-storyblok"
]
}
}
41 changes: 22 additions & 19 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import type { StoryData, StoryblokComponentType } from "@storyblok/react";
import type { ISbStoryData, StoryblokComponentType } from "@storyblok/react";

export interface SbGatsbyStory extends StoryData<StoryblokComponentType<string> & { [index: string]: any; }> {
export interface SbGatsbyStory extends ISbStoryData<StoryblokComponentType<string> & { [index: string]: any; }> {
internalId: number
}

export type {
AlternateObject,
Richtext,
RichtextInstance,
ISbConfig,
ISbCache,
ISbResult,
ISbResponse,
ISbError,
ISbNode,
ISbSchema,
ThrottleFn,
AsyncFn,
ArrayFn,
ISbContentMangmntAPI,
ISbManagmentApiResult,
ISbStories,
ISbStory,
ISbDimensions,
ISbStoryData,
ISbAlternateObject,
ISbStoriesParams,
ISbStoryParams,
ISbRichtext,
SbBlokData,
SbBlokKeyDataTypes,
SbRichTextOptions,
SbSDKOptions,
Stories,
StoriesParams,
Story,
StoryData,
StoryParams,
StoryblokBridgeConfigV2,
StoryblokBridgeV2,
StoryblokCache,
StoryblokCacheProvider,
StoryblokClient,
StoryblokComponentType,
StoryblokConfig,
StoryblokManagmentApiResult,
StoryblokResult,
apiPlugin,
useStoryblokBridge,
SbReactComponentsMap,
SbReactSDKOptions
} from "@storyblok/react";
4 changes: 2 additions & 2 deletions lib/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export default defineConfig(() => {
format === "es" ? `${libName}.mjs` : `${libName}.js`,
},
rollupOptions: {
external: ["react", "axios"],
external: ["react"],
output: {
globals: { react: "React" },
},
},
},
};
});
});
106 changes: 55 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
"semi": true,
"singleQuote": false
}
}
}

0 comments on commit 35d76e7

Please sign in to comment.