forked from UKSOURCE/hailearning.edu.vn
feat: Refactor blog components and add pagination
This commit is contained in:
@@ -1,224 +1,116 @@
|
||||
import Link from "next/link";
|
||||
import type { BlogPost } from "@/types/blog";
|
||||
import { editorjsToHtml, getCmsImageUrl } from "@/utils";
|
||||
import { toSlug } from "@/utils/slugify";
|
||||
import CommentsSection from "./CommentsSection";
|
||||
|
||||
interface NewsDetailsContentProps {
|
||||
post: BlogPost;
|
||||
}
|
||||
|
||||
export default function NewsDetailsContent({ post }: NewsDetailsContentProps) {
|
||||
// Get comments from post (already included in API response)
|
||||
const postComments = post.comments || [];
|
||||
|
||||
// Get base URL for EditorJS images
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
|
||||
|
||||
// Convert EditorJS content to HTML
|
||||
const renderContent = () => {
|
||||
const html = editorjsToHtml(post.content, baseUrl);
|
||||
return { __html: html };
|
||||
};
|
||||
|
||||
// Convert EditorJS contentAfterQuote to HTML
|
||||
const renderContentAfterQuote = () => {
|
||||
const html = editorjsToHtml(post.contentAfterQuote, baseUrl);
|
||||
return { __html: html };
|
||||
};
|
||||
|
||||
export default function NewsDetailsContent() {
|
||||
return (
|
||||
<div className="col-lg-8 col-12">
|
||||
<div className="news-details-post">
|
||||
<div className="news-details-image">
|
||||
<img src="/assets/img/inner-page/news-details/details-1.jpg" alt="img" />
|
||||
<img
|
||||
src={getCmsImageUrl(post.featuredImage) || "/assets/img/inner-page/news-details/details-1.jpg"}
|
||||
alt={post.title}
|
||||
/>
|
||||
</div>
|
||||
<div className="details-content">
|
||||
<ul className="news-list">
|
||||
<li>
|
||||
<i className="fa-solid fa-user"></i>
|
||||
By Admin
|
||||
<i className="fa-solid fa-user"></i> By {post.author}
|
||||
</li>
|
||||
<li>
|
||||
<i className="fa-solid fa-calendar-days"></i>
|
||||
11 March 2025
|
||||
<i className="fa-solid fa-calendar-days"></i> {post.publishedAt}
|
||||
</li>
|
||||
<li>
|
||||
<i className="fa-solid fa-comments"></i>
|
||||
0 Comments
|
||||
<i className="fa-solid fa-comments"></i> {postComments.length} Comments
|
||||
</li>
|
||||
</ul>
|
||||
<h2>Work Visa vs. Student Visa Which is Right for You?</h2>
|
||||
<p>
|
||||
Choosing between a work visa and a student visa depends on your career and academic goals. A
|
||||
student visa allows you to pursue higher education abroad, gain international exposure, and
|
||||
sometimes work part-time while studying. On the other hand, a work visa is for professionals
|
||||
seeking employment opportunities and long-term career growth in another country.
|
||||
</p>
|
||||
<p className="mt-4 mb-3">
|
||||
Both options have unique benefits, eligibility requirements, and future pathways. Understanding
|
||||
your personal ambitions, financial plans, and long-term vision will help you decide which visa
|
||||
option best suits your journey.
|
||||
</p>
|
||||
<h3>Work Visa vs. Student Visa: Which is Right for You?</h3>
|
||||
<p className="mt-2 mb-3">
|
||||
Choosing between a student visa and a work visa is a major decision that shapes your future
|
||||
abroad. Both visa types open unique opportunities, but the right choice depends on your goals,
|
||||
priorities, and resources. A student visa is designed for individuals who wish to pursue higher
|
||||
education in a foreign country.
|
||||
</p>
|
||||
<div className="row g-4">
|
||||
<div className="col-lg-6">
|
||||
<div className="thumb">
|
||||
<img src="/assets/img/inner-page/news-details/details-2.jpg" alt="img" />
|
||||
</div>
|
||||
<h2>{post.title}</h2>
|
||||
<div dangerouslySetInnerHTML={renderContent()} />
|
||||
|
||||
{/* Gallery Images */}
|
||||
{post.galleryImages && post.galleryImages.length > 0 && (
|
||||
<div className="row g-4 mt-4">
|
||||
{post.galleryImages.map((image, index) => (
|
||||
<div key={index} className={post.galleryImages!.length === 1 ? "col-12" : "col-lg-6"}>
|
||||
<div className="thumb">
|
||||
<img src={getCmsImageUrl(image)} alt={`${post.title} - Image ${index + 1}`} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="col-lg-6">
|
||||
<div className="thumb">
|
||||
<img src="/assets/img/inner-page/news-details/details-3.jpg" alt="img" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Quote/Sidebar */}
|
||||
{post.quote && (
|
||||
<div className="sideber mt-4 mb-3">
|
||||
<h5>{post.quote}</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div className="sideber">
|
||||
<h5>
|
||||
This blog really helped me understand the difference between student and work visas. The
|
||||
explanations were clear and practical.
|
||||
</h5>
|
||||
</div>
|
||||
<p className="mb-3">
|
||||
It provides access to world-class universities, cultural exposure, and global networking
|
||||
opportunities. With a student visa, you may also get part-time work rights, which can help support
|
||||
your expenses and give you valuable international work experience. However, the primary focus
|
||||
remains on academics and personal growth. On the other hand, a work visa is perfect for those who
|
||||
want to establish themselves in a career overseas.
|
||||
</p>
|
||||
<p>
|
||||
It provides immediate access to job markets, stable income, and often a pathway to permanent
|
||||
residency. Work visas are suitable for skilled professionals who are ready to contribute to the
|
||||
global workforce and achieve long-term career goals. Ultimately, the choice comes down to your
|
||||
personal aspirations. If education and exploration are your priorities, a student visa is ideal. If
|
||||
career advancement and stability are your goals, a work visa is the right fit.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Content After Quote */}
|
||||
{post.contentAfterQuote && (
|
||||
<div dangerouslySetInnerHTML={renderContentAfterQuote()} />
|
||||
)}
|
||||
|
||||
{/* Tags and Social Share */}
|
||||
<div className="row tag-share-wrap mt-4 mb-5">
|
||||
<div className="col-lg-8 col-12">
|
||||
<div className="tagcloud">
|
||||
<span>Tags:</span>
|
||||
<Link href="/blog/work-visa">WorkVisa</Link>
|
||||
<Link href="/blog/family-visa">FamilyVisa</Link>
|
||||
<Link href="/blog/student-visa">StudentVisa</Link>
|
||||
{post.tags.map((tagName) => {
|
||||
// Generate slug from tag name (Vietnamese-friendly)
|
||||
const tagSlug = toSlug(tagName);
|
||||
return (
|
||||
<Link key={tagName} href={`/blog/tag/${tagSlug}`}>
|
||||
{tagName}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-4 col-12 mt-3 mt-lg-0 text-lg-end">
|
||||
<div className="social-share">
|
||||
<a href="#">
|
||||
<a href="#" aria-label="Share on Twitter">
|
||||
<i className="fab fa-twitter"></i>
|
||||
</a>
|
||||
<a href="#">
|
||||
<a href="#" aria-label="Share on YouTube">
|
||||
<i className="fa-brands fa-youtube"></i>
|
||||
</a>
|
||||
<a href="#">
|
||||
<a href="#" aria-label="Share on LinkedIn">
|
||||
<i className="fab fa-linkedin-in"></i>
|
||||
</a>
|
||||
<a href="#">
|
||||
<a href="#" aria-label="Share on Facebook">
|
||||
<i className="fab fa-facebook-f"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="comments-area">
|
||||
<div className="comments-heading">
|
||||
<h3>02 Comments</h3>
|
||||
</div>
|
||||
<div className="news-single-comment d-flex gap-4 pt-4 pb-0">
|
||||
<div className="image">
|
||||
<img src="/assets/img/inner-page/news-details/comment-1.png" alt="image" />
|
||||
</div>
|
||||
<div className="content">
|
||||
<div className="head d-flex flex-wrap gap-2 align-items-center justify-content-between">
|
||||
<div className="con">
|
||||
<span>February 10, 2024</span>
|
||||
<h4>Frank Flores</h4>
|
||||
</div>
|
||||
<Link href="/blog/work-visa" className="reply">
|
||||
Reply
|
||||
</Link>
|
||||
</div>
|
||||
<p className="mt-30 mb-4">
|
||||
Neque porro est qui dolorem ipsum quia quaed inventor veritatis et quasi architecto var sed
|
||||
efficitur turpis gilla sed sit amet finibus eros. Lorem Ipsum is simply dummy
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="news-single-comment style-2 d-flex gap-4 pt-4 pb-0">
|
||||
<div className="image">
|
||||
<img src="/assets/img/inner-page/news-details/comment-2.png" alt="image" />
|
||||
</div>
|
||||
<div className="content">
|
||||
<div className="head d-flex flex-wrap gap-2 align-items-center justify-content-between">
|
||||
<div className="con">
|
||||
<h4>Charlie Tushar</h4>
|
||||
<span>February 10, 2024</span>
|
||||
</div>
|
||||
<Link href="/blog/work-visa" className="reply">
|
||||
Reply
|
||||
</Link>
|
||||
</div>
|
||||
<p className="mt-30 mb-4">
|
||||
Neque porro est qui dolorem ipsum quia quaed inventor veritatis et quasi architecto var sed
|
||||
efficitur turpis gilla sed sit amet finibus eros. Lorem Ipsum is simply dummy
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="news-single-comment d-flex gap-4 pt-4 pb-4">
|
||||
<div className="image">
|
||||
<img src="/assets/img/inner-page/news-details/comment-3.png" alt="image" />
|
||||
</div>
|
||||
<div className="content">
|
||||
<div className="head d-flex flex-wrap gap-2 align-items-center justify-content-between">
|
||||
<div className="con">
|
||||
<span>February 10, 2024 </span>
|
||||
<h4>Fatma Sariqul</h4>
|
||||
</div>
|
||||
<Link href="/blog/work-visa" className="reply">
|
||||
Reply
|
||||
</Link>
|
||||
</div>
|
||||
<p className="mt-30 mb-4">
|
||||
Neque porro est qui dolorem ipsum quia quaed inventor veritatis et quasi architecto var sed
|
||||
efficitur turpis gilla sed sit amet finibus eros. Lorem Ipsum is simply dummy
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 className="mb-3">Leave A Comment</h3>
|
||||
<form
|
||||
action="contact.php"
|
||||
id="contact-form1"
|
||||
method="POST"
|
||||
className="contact-form-items"
|
||||
>
|
||||
<div className="row g-4">
|
||||
<div className="col-lg-4">
|
||||
<div className="form-clt">
|
||||
<span>Your Name</span>
|
||||
<input type="text" name="name" id="name331" placeholder="Your name" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-4">
|
||||
<div className="form-clt">
|
||||
<span>Your Email</span>
|
||||
<input type="text" name="name" id="email11" placeholder="Your email" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-4">
|
||||
<div className="form-clt">
|
||||
<span>Your Phone</span>
|
||||
<input type="text" name="name" id="name22" placeholder="Phone Number" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-6">
|
||||
<div className="form-clt">
|
||||
<span>Your Address</span>
|
||||
<input type="text" name="name" id="name24" placeholder="Address Now" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-6">
|
||||
<div className="form-clt">
|
||||
<span>Your Date</span>
|
||||
<input type="text" name="name" id="name25" placeholder="Date" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-12">
|
||||
<div className="form-clt">
|
||||
<textarea
|
||||
name="message"
|
||||
id="message1"
|
||||
placeholder="Type your message"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-12 wow fadeInUp" data-wow-delay=".3s">
|
||||
<button type="submit" className="theme-btn">
|
||||
Send Message
|
||||
<i className="fa-solid fa-arrow-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<CommentsSection slug={post.slug} comments={postComments} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user