Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/refactor how to render #20

Merged
merged 7 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"axios": "^0.27.2",
"dotenv": "^16.0.1",
"framer-motion": "^6.5.1",
"lodash": "^4.17.21",
"node-html-parser": "^5.3.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand Down
Binary file added src/fonts/AlegreyaSans-Medium.ttf
Binary file not shown.
5 changes: 5 additions & 0 deletions src/fonts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const Fonts = () => (
font-family: 'Alegreya Sans Thin';
src: url('./fonts/AlegreyaSans-Light.ttf');
}

@font-face {
font-family: 'Alegreya Sans Medium';
src: url('./fonts/AlegreyaSans-Medium.ttf');
}
`}
/>
);
Expand Down
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
src: url('./fonts/AlegreyaSans-Light.ttf');
}

@font-face {
font-family: 'Alegreya Sans Medium';
src: url('./fonts/AlegreyaSans-Medium.ttf');
}

*,
::before,
::after {
Expand Down
42 changes: 26 additions & 16 deletions src/pages/Detailpage/Detailpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ import { DetailpageProps } from '../../types/interface';
import useFetch from '../../hooks/useFetch';
import Loading from '../Loading';
import PageNotFound from '../PageNotFound';
import { DetailPost } from '@/types/types';

const Detailpage: React.FC<DetailpageProps> = () => {
const { postId } = useParams();
const { data, isLoading, error } = useFetch(fetchSinglePost(postId!));

let post: any;
let post: DetailPost;
let published_at: string;

if (data) {
post = data;
const date = new Date(post.published_at);
const date = new Date(post.published_at!);
published_at = `${date.getDate()} ${
months[date.getMonth()]
} ${date.getFullYear()}`;
Expand All @@ -40,23 +41,35 @@ const Detailpage: React.FC<DetailpageProps> = () => {
<Box width="100%" height="100%" />
</Flex>
<Flex className="my-36" flexDirection="column" width="70%">
<Box
fontFamily="Alegreya"
fontSize={{
base: '14px',
md: '18px',
}}
<div
className={
'font-Body text-overline md:text-body cursor-pointer'
}
>
{'Home > Category > Kemahasiswaan'}
</Box>
<a className={'hover:underline'} href={'/'}>
{'Home'}
</a>
{post!.primary_tag && (
<span>
{' '}
{'>'}{' '}
<a
className={'hover:underline'}
href={`/search?${post!.primary_tag.name}`}
>
{post!.primary_tag.name}
</a>
</span>
)}
</div>
<Box
fontFamily="Magilio"
fontSize={{
base: '20px',
md: '35px',
}}
>
{post.title}
{post!.title}
</Box>
<Box
fontFamily="Alegreya"
Expand All @@ -74,12 +87,9 @@ const Detailpage: React.FC<DetailpageProps> = () => {
}}
>
<Box maxWidth="100%">
<img
src="http://localhost:2368/content/images/2022/07/IMG_6351.jpg"
alt="featured"
/>
<img src={post!.feature_image!} alt="featured" />
</Box>
{renderHTMLContent(post)}
{renderHTMLContent(post!)}
</VStack>
</Flex>
<Flex width="15%" />
Expand Down
Loading