parent
6502ae47c3
commit
5bbe02ac94
File diff suppressed because it is too large
Load Diff
@ -1,47 +1,58 @@
|
|||||||
import { Title, Text, Container, rem, createStyles, TypographyStylesProvider } from '@mantine/core';
|
import { Title, Container, rem, createStyles, TypographyStylesProvider, Image } from '@mantine/core';
|
||||||
|
import { Carousel } from '@mantine/carousel';
|
||||||
import { useLoaderData } from 'react-router-dom';
|
import { useLoaderData } from 'react-router-dom';
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
content: {
|
content: {
|
||||||
padding: rem(30)
|
padding: rem(30)
|
||||||
},
|
},
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
fontSize: rem(55),
|
fontSize: rem(55),
|
||||||
lineHeight: 1.2,
|
lineHeight: 1.2,
|
||||||
fontWeight: 900,
|
fontWeight: 900,
|
||||||
paddingBottom: rem(20),
|
paddingBottom: rem(20),
|
||||||
[theme.fn.smallerThan('xs')]: {
|
[theme.fn.smallerThan('xs')]: {
|
||||||
fontSize: rem(28),
|
fontSize: rem(28),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
heading2: {
|
heading2: {
|
||||||
color: theme.colorScheme === 'dark' ? theme.white : theme.black,
|
color: theme.colorScheme === 'dark' ? theme.white : theme.black,
|
||||||
paddingTop: rem(11)
|
paddingTop: rem(11)
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function Article() {
|
export function Article() {
|
||||||
const articleData = useLoaderData();
|
const articleData = useLoaderData();
|
||||||
const { classes } = useStyles();
|
const { classes } = useStyles();
|
||||||
const article = articleData.data[0].attributes
|
const article = articleData.data[0].attributes
|
||||||
|
console.log(articleData)
|
||||||
return (
|
|
||||||
<Container className={classes.content}>
|
const generateCarousel = () => {
|
||||||
<Title order={1} className={classes.title}>
|
if (articleData.data[0].attributes.carousel.data) {
|
||||||
{article.title}
|
return (
|
||||||
</Title>
|
<Carousel slideSize="70%" height={500} slideGap="md" loop>
|
||||||
<Text>
|
{articleData.data[0].attributes.carousel.data.map(image => <Carousel.Slide><Image fit='fill' height={500} mx="auto" radius="md" src={`http://strapi.wg.gateway.ts${image.attributes.url}`} alt="Random image" /></Carousel.Slide>)}
|
||||||
<TypographyStylesProvider>
|
</Carousel>
|
||||||
<Markdown>{article.content}</Markdown>
|
)
|
||||||
</TypographyStylesProvider>
|
}
|
||||||
</Text>
|
|
||||||
</Container>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container className={classes.content}>
|
||||||
|
<Title order={1} className={classes.title}>
|
||||||
|
{article.title}
|
||||||
|
</Title>
|
||||||
|
<TypographyStylesProvider>
|
||||||
|
<Markdown>{article.content}</Markdown>
|
||||||
|
</TypographyStylesProvider>
|
||||||
|
{generateCarousel()}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue