🖥FrontEnd/React

docusaurus에서 최신 블로그 글 가져오기

hellohailie 2023. 4. 5. 15:09

◆ docusaurus에서 최신 블로그 글 가져오는 방법 (사진이나 글쓴이 없이 제목과 링크만 가져오는 방법)

import React from 'react'
import recentPosts from '../../../../.docusaurus/docusaurus-plugin-content-blog/default/blog-post-list-prop-default.json'

const BlogItem = () => {
  //   console.log(recentPosts)
  return (
    <ul>
      {recentPosts.items.slice(0, 5).map((item, index) => (
        <li key={index}>
          <a href={`${item.permalink}`}>{item.title}</a>
        </li>
      ))}
    </ul>
  )
}

export default BlogItem

 

참고)

https://stackoverflow.com/questions/60289432/docusaurus-v2-recent-blogs-list-for-homepage

 

Docusaurus v2 - recent blogs list for homepage

in Docusaurus v2 is there a way to generate a list of recent blogs that can then be used to populate a block on the front page (src/pages/index.js)? I'm thinking something similar to how the features

stackoverflow.com

 

 

 

◆ docusaurus에서 최신 블로그 글 가져오는 방법 (사진이나 글쓴이까지 모두 가져오는 방법)

 

참고)

 

https://docusaurus.io/docs/api/plugin-methods/lifecycle-apis#configureWebpack

 

Lifecycle APIs | Docusaurus

During the build, plugins are loaded in parallel to fetch their own contents and render them to routes. Plugins may also configure webpack or post-process the generated files.

docusaurus.io

 

https://kgajera.com/blog/display-recent-blog-posts-on-home-page-with-docusaurus/

 

Display Recent Blog Posts on Home Page with Docusaurus 2.0.0-beta.16 | Kishan Gajera

I've found Docusaurus to be a great tool for both documentation sites as well as blogs because it provides great functionality out of the box and lets you focus on your site's content. I'm in the process of migrating a few sites over to it. A common featur

kgajera.com