post summary html parsed

This commit is contained in:
VividTruthKeeper 2022-10-02 00:31:27 +05:00
parent 670026cc56
commit df00a82891
2 changed files with 8 additions and 7 deletions

View File

@ -270,11 +270,10 @@
background: $base-gray;
}
textarea {
p {
background: $base-gray;
cursor: default;
padding: 0.6rem 1.2rem;
resize: none;
font-size: 1.6rem;
border-radius: 0.5rem;
}

View File

@ -21,13 +21,14 @@ const Post = () => {
const [postData, setPostData] = useState<PostType>();
const { posts } = useContext<ContextType>(PostContext).postValue;
const { id } = useParams();
const parser = new DOMParser();
useEffect(() => {
if (posts) {
if (posts[0].id !== -1) {
posts.map((post: PostType) => {
if (post.id.toString() === id) {
setPostData(post);
// console.log(parser.parseFromString(post.summary, "text/xml"));
}
});
}
@ -66,10 +67,11 @@ const Post = () => {
</div>
<div className="post__content__block">
<h4>Summary</h4>
<textarea
readOnly
value={postData ? postData.summary : ""}
></textarea>
<p
dangerouslySetInnerHTML={{
__html: postData ? postData.summary : "",
}}
></p>
</div>
<div className="post__content__block">
<h4>Created</h4>