Skip to content

Commit

Permalink
Merge pull request #24 from Sorok-Dva/fix/admin/editTuto
Browse files Browse the repository at this point in the history
🎨 feat: Enhance tutorial preview with image support
  • Loading branch information
Sorok-Dva authored Aug 22, 2024
2 parents 114de2d + cfb4e00 commit fe5d6f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions src/pages/admin/tutorials/AddTutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { toast } from 'react-toastify'
import { ToastDefaultOptions } from 'utils/toastOptions'
import { slugify } from 'utils/slugify'
import { useNavigate } from 'react-router-dom'
import { Img as Image } from 'react-image'

const AdminContainer = styled.div`
padding: 2rem;
Expand Down Expand Up @@ -217,10 +218,30 @@ const AddTutorial = () => {

{isPreview && (
<PreviewContainer>
<h3>{title}</h3>
<div dangerouslySetInnerHTML={{ __html: content }} />
<div className="col-lg-8 col-md-12">
<div className="blog-details-desc">
{ image && (
<div className="d-flex justify-content-center">
<Image
src={ image }
alt="Image"
width={ 900 }
height={ 500 }
className="mx-auto d-block"
/>
</div>
) }
</div>
</div>
<h1 style={ { marginTop: '1rem' } }>{ title }</h1>

<div className="pt-5"
dangerouslySetInnerHTML={ {
__html: content.replace(/(<? *script)/gi, 'illegalscript')
} }>
</div>
</PreviewContainer>
)}
) }
</AdminContainer>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/admin/tutorials/EditTutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useAuth } from 'context/AuthContext'
import { Editor } from '@tinymce/tinymce-react'
import PageBanner from 'components/Common/PageBanner'
import { Link, useNavigate, useParams } from 'react-router-dom'
import { Tutorial } from 'types/tutorial'
import type { Tutorial } from 'types/tutorial'
import { toast } from 'react-toastify'
import { ToastDefaultOptions } from 'utils/toastOptions'
import { slugify } from 'utils/slugify'
Expand Down

0 comments on commit fe5d6f9

Please sign in to comment.