Skip to content

Commit

Permalink
Merge pull request #1314 from storyblok/bugfix/apostrophe-issue-richtext
Browse files Browse the repository at this point in the history
fix: apostrophe-issue-richtext
  • Loading branch information
alvarosabu authored Feb 6, 2025
2 parents eccb19a + 85f67e2 commit 41bbc73
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 208 deletions.
31 changes: 24 additions & 7 deletions playground/react/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import { StoryblokComponent, useStoryblok } from '@storyblok/react';
import React from 'react';
import { BrowserRouter, Link, Route, Routes } from 'react-router';
import Home from './pages/Home';
import RichtextPage from './pages/RichtextPage';

function App() {
const story = useStoryblok('home', { version: 'draft' });
return (
<BrowserRouter>
<div>
<nav>
<ul>
<li>
<Link to="/react">Home</Link>
</li>
<li>
<Link to="/react/test-richtext">Richtext</Link>
</li>
</ul>
</nav>

if (!story?.content) {
return <div>Loading...</div>;
}

return <StoryblokComponent blok={story.content} />;
<Routes>
<Route path="/" element={<Home />} />
<Route path="react" element={<Home />} />
<Route path="react/test-richtext" element={<RichtextPage />} />
</Routes>
</div>
</BrowserRouter>
);
}

export default App;
3 changes: 2 additions & 1 deletion playground/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import Feature from './components/feature';
import { apiPlugin, storyblokInit } from '@storyblok/react';
import IFrameEmbed from './components/iframe-embed';

// https://app.storyblok.com/#/me/spaces/147897
storyblokInit({
accessToken: 'd6IKUtAUDiKyAhpJtrLFcwtt',
accessToken: 'OurklwV5XsDJTIE1NJaD2wtt',
use: [apiPlugin],
components: {
'teaser': Teaser,
Expand Down
4 changes: 3 additions & 1 deletion playground/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
"dependencies": {
"@storyblok/react": "workspace:^",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"react-router": "^7.1.1"
},
"devDependencies": {
"@types/node": "^20.17.10",
"@types/react": "18.3.4",
"@vitejs/plugin-basic-ssl": "^1.2.0",
"vite": "^5.4.3"
}
}
19 changes: 19 additions & 0 deletions playground/react/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { StoryblokComponent, useStoryblok } from '@storyblok/react';
import React from 'react';

function Home() {
const story = useStoryblok('react', { version: 'draft' });

if (!story?.content) {
return <div>Loading...</div>;
}

return (
<div>
<h1>Home</h1>
<StoryblokComponent blok={story.content} />
</div>
);
}

export default Home;
16 changes: 16 additions & 0 deletions playground/react/pages/RichtextPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StoryblokRichText, useStoryblok } from '@storyblok/react';
import React from 'react';

function RichtextPage() {
const story = useStoryblok('react/test-richtext', { version: 'draft' });

if (!story?.content) {
return <div>Loading...</div>;
}

return (
story.content.richText && <StoryblokRichText doc={story.content.richText} />
);
}

export default RichtextPage;
6 changes: 5 additions & 1 deletion playground/react/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'node:path';
import basicSsl from '@vitejs/plugin-basic-ssl';

export default defineConfig({
plugins: [react()],
plugins: [
react(),
basicSsl(),
],
resolve: {
alias: {
'@storyblok/react': resolve(__dirname, '../../src/index.ts'),
Expand Down
Loading

0 comments on commit 41bbc73

Please sign in to comment.