Skip to content

Commit

Permalink
Merge pull request #30 from storyblok/fix/china-custom-parent
Browse files Browse the repository at this point in the history
Fix: china custom parent
  • Loading branch information
Lisi Linhart authored Sep 21, 2023
2 parents 0d782aa + bfbcdce commit 6154194
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/commands/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import frameworks from '../lib/frameworks'
import clone from '../lib/clone'
import replace from '../lib/replace'
import regions, {Region} from '../lib/regions'
import {addCustomParentFramework} from '../lib/helper-replace'

export default class CreateStoryblokAppCommand extends Command {
static description = 'The CLI tool for quickly starting a Storyblok project';
Expand Down Expand Up @@ -173,6 +174,15 @@ export default class CreateStoryblokAppCommand extends Command {
"region: '" + spaceRegion.toLowerCase() + "'"
}

if (spaceRegion === 'CN') {
addCustomParentFramework({
folder,
framework,
frameworkDetails,
localhostPath: 'https://app.storyblokchina.cn',
})
}

replace(path.join(folder, frameworkDetails.config), replacements)

const pathEditing = `${selectedRegion.urlUi}/#/edit/${storyId}${regionParam}`
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helper-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function addCustomParentFramework({
return
case 'sveltekit':
replace(`./${folder}/${frameworkDetails.bridge}`, {
'useStoryblokBridge(story.id, (newStory) => (story = newStory))': `useStoryblokBridge(story.id, (newStory) => (story = newStory), { customParent: '${localhostPath}'})`,
'useStoryblokBridge(data.story.id, (newStory) => (data.story = newStory))': `useStoryblokBridge(data.story.id, (newStory) => (data.story = newStory), { customParent: '${localhostPath}'})`,
})
}
}

0 comments on commit 6154194

Please sign in to comment.