Skip to content

Commit

Permalink
Merge pull request #142 from storyblok/fix/resolverInstance
Browse files Browse the repository at this point in the history
fix: add resolverInstance for Nuxt, Astro and other SDKs
  • Loading branch information
manuelschroederdev authored Sep 23, 2022
2 parents a104889 + a0f957e commit be34a48
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Richtext,
StoryblokComponentType,
SbRichTextOptions,
RichtextInstance,
} from "./types";

import RichTextResolver from "storyblok-js-client/source/richTextResolver";
Expand Down Expand Up @@ -110,9 +111,11 @@ const setComponentResolver = (resolver, resolveFn) => {

export const renderRichText = (
data: Richtext,
options?: SbRichTextOptions
options?: SbRichTextOptions,
resolverInstance?: RichtextInstance,
): string => {
if (!richTextResolver) {
let localResolver = resolverInstance || richTextResolver;
if (!localResolver) {
console.error(
"Please initialize the Storyblok SDK before calling the renderRichText function"
);
Expand All @@ -128,7 +131,6 @@ export const renderRichText = (
return "";
}

let localResolver = richTextResolver;
if (options) {
localResolver = new RichTextResolver(options.schema);
if (options.resolver) {
Expand Down

0 comments on commit be34a48

Please sign in to comment.