forked from polka_billy/porridger
Updated poetry to use latest api
Added poem id, changed url, fixed formatting, enabled actual fetching
This commit is contained in:
@ -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>
|
||||
</>
|
||||
)
|
||||
|
Reference in New Issue
Block a user