Updated poetry to use latest api

Added poem id, changed url, fixed formatting, enabled actual fetching
This commit is contained in:
2023-08-08 18:30:29 +03:00
parent ea18439140
commit 60779ea489
5 changed files with 31 additions and 124 deletions

View File

@ -1,18 +1,13 @@
import { CSSProperties } from 'react'
import { usePoetry } from '../hooks/api'
import { gotError, gotResponse } from '../hooks/useFetch'
const styles = {
container: {
paddingBottom: 8,
} as CSSProperties,
}
import styles from '../styles/Poetry.module.css'
function Poetry() {
const poetry = usePoetry()
return (
<div style={styles.container}>
<div className={styles.container}>
<h4 className='fw-bold'>Поэзия</h4> {
gotResponse(poetry) ? (
gotError(poetry) ? (
@ -23,7 +18,13 @@ function Poetry() {
) : (
<>
<h5>{poetry.data.title}</h5>
<p dangerouslySetInnerHTML={{ __html: poetry.data.text }} />
<p
className={styles.text}
dangerouslySetInnerHTML={{
__html:
poetry.data.text.trim().replace(/(\n){3,}/g, '\n\n'),
}}
/>
<p><em>{poetry.data.author}</em></p>
</>
)