Skip to content

Commit

Permalink
feat: bump major version
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove axios
  • Loading branch information
schabibi1 committed Jan 16, 2023
1 parent e587e80 commit b3219e1
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 79 deletions.
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
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
6 changes: 3 additions & 3 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.3",
"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
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";
2 changes: 1 addition & 1 deletion lib/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig(() => {
format === "es" ? `${libName}.mjs` : `${libName}.js`,
},
rollupOptions: {
external: ["react", "axios"],
external: ["react"],
output: {
globals: { react: "React" },
},
Expand Down
109 changes: 58 additions & 51 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@
"tabWidth": 2,
"semi": true,
"singleQuote": false
},
"dependencies": {
"isomorphic-fetch": "^3.0.0"
}
}
}

0 comments on commit b3219e1

Please sign in to comment.