Skip to content
Merged
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
25 changes: 20 additions & 5 deletions src/pages/blogs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import Layout from "@theme/Layout";
import Link from "@docusaurus/Link";
import { useHistory } from "@docusaurus/router";
import blogs from "../../database/blogs/index";
import Head from "@docusaurus/Head";
import { getAuthorProfiles } from "../../utils/authors";
Expand Down Expand Up @@ -233,6 +234,8 @@ export default function Blogs() {

const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
const authors = getAuthorProfiles(blog.authors || []);
const history = useHistory();
const blogPath = `/blog/${blog.slug}`;

// Tags — use blog.tags if present, fallback to blog.category as single tag
const tags: string[] =
Expand All @@ -243,7 +246,19 @@ const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
: [];

return (
<div className="article-card">
<div
className="article-card"
role="link"
tabIndex={0}
aria-label={`Read ${blog.title}`}
onClick={() => history.push(blogPath)}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
history.push(blogPath);
}
}}
>
{/* ── Image ── */}
<div className="card-image">
<img src={blog.image} alt={blog.title} loading="lazy" />
Expand All @@ -253,9 +268,7 @@ const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
<div className="card-content">
{/* Title */}
<h3 className="card-title">
<Link to={`/blog/${blog.slug}`} className="card-title-link">
{blog.title}
</Link>
<span className="card-title-link">{blog.title}</span>
</h3>

{/* Description */}
Expand Down Expand Up @@ -302,6 +315,7 @@ const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
target="_blank"
rel="noopener noreferrer"
title={author.name}
onClick={(event) => event.stopPropagation()}
>
{author.imageUrl ? (
<img
Expand Down Expand Up @@ -340,6 +354,7 @@ const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
target="_blank"
rel="noopener noreferrer"
title={author.name}
onClick={(event) => event.stopPropagation()}
>
{author.name}
</Link>
Expand All @@ -354,7 +369,7 @@ const BlogCard = ({ blog }: { blog: (typeof blogs)[number] }) => {
</div>

{/* Read link */}
<Link to={`/blog/${blog.slug}`} className="card-read-link">
<Link to={blogPath} className="card-read-link">
Read →
</Link>
</div>
Expand Down
Loading