0

我正在尝试使用 react-router 动态呈现每篇博客文章。我从 Contentful API 获取两个博客。BlogCards 组件用于通过卡片呈现博客。如何使用他们的 id 动态呈现每个博客?

import React from 'react'
import '../BlogCards/BlogCard.scss'
import {Link}from 'react-router-dom'

function BlogCards() {
    return (
            <>
          
        <div className="blog-card__info">
          <h5>HARVICK GETS WHAT HE NEEDS, JOHNSON AMONG THOSE</h5>
        </div>
        <Link to='/blog'>
        <a href="#" className="btn btn--with-icon"><i className="btn-icon fa fa-long-arrow-right"></i>READ MORE</a>
        </Link>

    </> 
    )   
}

export default BlogCards

return (
        <div>
          <h1 className="header">Blog</h1>
          {blogs.map((blog)=>
            <Article key={blog.sys.id} title={blog.fields.title} introduction={blog.fields.introduction} mainBody1={blog.fields.mainBody1} mainBody2={blog.fields.mainBody2}  />
          )}
        </div>
    )

4

0 回答 0