選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

BlogArticlesDataWrapper.jsx 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React, { useEffect, useState } from 'react';
  2. import { strapiApiBuilder } from './../../utils/strapiApiBuilder';
  3. import useFetchCollections from './../../hooks/useFetchCollections';
  4. import Wrapper from '../../layout/Wrapper';
  5. import Animation_Diligent from '../../assets/animation_diligent.webm';
  6. import ArticlesGrid from './ArticlesGrid';
  7. import ArticleCard from './ArticleCard';
  8. const api_url = process.env.REACT_APP_API_URL;
  9. const strapiPopulate = [
  10. 'AuthorImage',
  11. 'ArticleImage',
  12. 'article_category',
  13. ];
  14. const BlogArticlesDataWrapper = () => {
  15. const strapi = strapiApiBuilder('articles', strapiPopulate, '');
  16. const [{ data, isLoading, isError }, doFetch] = useFetchCollections(strapi);
  17. if (isLoading) {
  18. return (
  19. <div className="z-50 w-full h-screen bg-white dark:bg-dg-primary-1700 overflow-hidden dark:text-white flex items-center justify-center text-3xl font-semibold">
  20. <video id="animation" width="540" height="540" autoPlay muted loop>
  21. <source src={Animation_Diligent} type="video/webm" />
  22. Loading...
  23. </video>
  24. </div>
  25. );
  26. } else {
  27. return <>{data && <Wrapper>
  28. <ArticlesGrid>
  29. {data.map((element,index) => (
  30. <div key={index}>
  31. <ArticleCard data={element.attributes} />
  32. </div>
  33. )
  34. )}
  35. </ArticlesGrid>
  36. </Wrapper>}</>;
  37. }
  38. };
  39. export default BlogArticlesDataWrapper;