Skip to content

Commit 6141f09

Browse files
committed
modified: package.json
modified: pnpm-lock.yaml new file: src/app/_components/carousel.tsx modified: src/app/_components/container.tsx modified: src/app/_components/more-stories.tsx new file: src/app/_components/tag.tsx new file: src/app/_components/tagAction.tsx modified: src/app/blog/page.tsx
1 parent e535b77 commit 6141f09

8 files changed

Lines changed: 170 additions & 6 deletions

File tree

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"react-dom": "^19.0.0",
2323
"react-emoji-render": "^2.0.1",
2424
"react-icons": "^5.5.0",
25+
"react-slick": "^0.30.3",
2526
"remark": "^15.0.1",
2627
"remark-gfm": "^4.0.1",
2728
"remark-html": "^16.0.1",
2829
"remark-parse": "^11.0.0",
30+
"slick-carousel": "^1.8.1",
2931
"unified": "^11.0.5"
3032
},
3133
"devDependencies": {
@@ -34,6 +36,7 @@
3436
"@types/node": "^20",
3537
"@types/react": "^19",
3638
"@types/react-dom": "^19",
39+
"@types/react-slick": "^0.23.13",
3740
"eslint": "^9",
3841
"eslint-config-next": "15.1.7",
3942
"postcss": "^8",

pnpm-lock.yaml

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/_components/carousel.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// components/Carousel.js
2+
"use client"
3+
import React from 'react';
4+
import Slider from 'react-slick';
5+
import 'slick-carousel/slick/slick.css';
6+
import 'slick-carousel/slick/slick-theme.css';
7+
8+
const Carousel = ({children}:React.PropsWithChildren) => {
9+
const settings = {
10+
infinite: true,
11+
slidesToShow: 2,
12+
slidesToScroll: 1,
13+
autoplay: true,
14+
autoplaySpeed: 2000,
15+
rtl: true
16+
};
17+
return (
18+
<div className="slider-container">
19+
<Slider {...settings}>
20+
{children}
21+
</Slider>
22+
</div>
23+
);
24+
};
25+
26+
export default Carousel;

src/app/_components/container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type Props = {
33
};
44

55
const Container = ({ children }: Props) => {
6-
return <div className="container mx-auto px-5">{children}</div>;
6+
return <div className=" mx-auto px-5">{children}</div>;
77
};
88

99
export default Container;

src/app/_components/more-stories.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Post } from "@/interfaces/post";
22
import { PostPreview } from "./post-preview";
3+
import Carousel from "./carousel"
34

45
type Props = {
56
posts: Post[];
@@ -14,7 +15,8 @@ export function MoreStories({ posts }: Props) {
1415
{/* update pertama */}
1516
{/* <div className="grid grid-cols-1 md:grid-cols-2 md:gap-x-16 lg:gap-x-32 gap-y-20 md:gap-y-32 mb-32"> */}
1617
{/* update kedua */}
17-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4">
18+
<Carousel>
19+
{/* <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4"> */}
1820
{posts.map((post) => (
1921
<PostPreview
2022
key={post.slug}
@@ -26,7 +28,8 @@ coverImage={post.coverImage}
2628
excerpt={post.excerpt}
2729
/>
2830
))}
29-
</div>
31+
{/* </div> */}
32+
</Carousel>
3033
</section>
3134
);
3235
}

src/app/_components/tag.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// components/Tag.js
2+
"use client"
3+
import React from 'react';
4+
5+
6+
type Props = {
7+
label: string;
8+
color:string;
9+
slug: string;
10+
Close?: any;
11+
};
12+
export function handleClose(label:string) {
13+
console.log(`Tag "${label}" closed!`);
14+
// Lakukan operasi server di sini, seperti memanggil API atau mengakses database.
15+
}
16+
17+
export const Tag = ({ label, color = 'bg-blue-500', Close }:Props) => {
18+
const handleClick = () => {
19+
if (Close) {
20+
Close(label);
21+
}
22+
};
23+
24+
25+
return (
26+
<div className={`inline-flex items-center ${color} text-white px-2 py-1 rounded-md text-sm mr-2`}>
27+
{label}
28+
{Close && (
29+
<button className="ml-2 text-white hover:text-gray-200" onClick={handleClick}>
30+
&times;
31+
</button>
32+
)}
33+
</div>
34+
);
35+
};
36+

src/app/_components/tagAction.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Tag,handleClose} from "@/app/_components/tag"
2+
3+
type Props = {
4+
label: string;
5+
color:string;
6+
slug: string;
7+
Close?: any;
8+
};
9+
10+
export default function TagRelease(props:Props[]){
11+
return(
12+
<div>
13+
{props.map(Tag)}
14+
</div>)
15+
}

src/app/blog/page.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ import { HeroPost } from "@/app/_components/hero-post";
33
import { Intro } from "@/app/_components/intro";
44
import { MoreStories } from "@/app/_components/more-stories";
55
import { getAllPosts } from "@/lib/api";
6+
// import { handleClose } from '@/app/_components/tagAction';
67

78
export default function Index() {
89
const allPosts = getAllPosts();
9-
1010
const heroPost = allPosts[0];
11-
1211
const morePosts = allPosts.slice(1);
13-
12+
/* edit */
13+
const label = allPosts.map(lbl=>lbl.title)
14+
const color = ""
15+
console.log(label[0])
16+
1417
return (
1518
<main>
1619
<Container>
@@ -24,6 +27,11 @@ export default function Index() {
2427
excerpt={heroPost.excerpt}
2528
/>
2629
{morePosts.length > 0 && <MoreStories posts={morePosts} />}
30+
{/* <Tag
31+
label={label}
32+
color={color?"bg-blue-500": ""}
33+
Close={()=>handleClose(label)}
34+
/> */}
2735
</Container>
2836
</main>
2937
);

0 commit comments

Comments
 (0)