You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ArticlePage.jsx 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import React, { Children, Fragment, useEffect } from 'react';
  2. import CustomLink from '../components/root/CustomLink';
  3. import ActionCard from '../components/shared/ActionCard';
  4. import ReactMarkdown from 'react-markdown';
  5. import useDataApi from '../hooks/useDataApi';
  6. import Animation_Diligent from '../assets/animation_diligent.webm';
  7. import Wrapper from '../layout/Wrapper';
  8. import PageLayout from '../layout/PageLayout';
  9. import '../App.css';
  10. import '../styles/ck-editor.css';
  11. import useAnalytics from './../hooks/useAnalytics';
  12. import { strapiApiBuilder } from './../utils/strapiApiBuilder';
  13. import ReactHelmet from './../components/shared/ReactHelmet';
  14. import { useLocation } from 'react-router-dom';
  15. import useFetchCollections from './../hooks/useFetchCollections';
  16. import OneArticlesGrid from '../components/OneArticleGrid';
  17. import LatestArticles from './../components/LatestArticles';
  18. import { ReactComponent as BackArrowSVG } from '../assets/icons/back-triangle.svg';
  19. import DynamicZones from '../components/DynamicZones';
  20. import BlogHeadingSection from './../components/BlogHeadingSection';
  21. const api_url = process.env.REACT_APP_API_URL;
  22. const strapiPopulate = [
  23. 'DynamicZone1.Image',
  24. 'DynamicZone1.Image.field',
  25. 'DynamicZone1.ImagesGrid',
  26. 'DynamicZone1.ImagesGrid.field',
  27. ];
  28. export default function ArticlePage() {
  29. const slug = useLocation();
  30. const helperString = slug.pathname.split('/').pop();
  31. const strapi = strapiApiBuilder(
  32. 'articles?populate[DynamicZone1][populate]=*&populate[AuthorImage][populate]=*&populate[ArticleImage][populate]=*&populate[article_category][populate]=*',
  33. [],
  34. `&filters[Slug][$eq]=${helperString}`,
  35. );
  36. const [{ data, isLoading, isError }, doFetch] = useFetchCollections(strapi);
  37. console.log(data);
  38. useAnalytics('');
  39. useEffect(() => {
  40. document.title = '';
  41. }, []);
  42. if (isLoading) {
  43. return (
  44. <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">
  45. <video id="animation" width="540" height="540" autoPlay muted loop>
  46. <source src={Animation_Diligent} type="video/webm" />
  47. Loading...
  48. </video>
  49. </div>
  50. );
  51. } else {
  52. return (
  53. <PageLayout>
  54. {data && (
  55. <div className="mt-[80px] md:mt-[140px]">
  56. <Wrapper>
  57. <div className="flex flex-col gap-8 md:gap-12">
  58. <a href={'/blog'} className="flex gap-4 items-center md:mb-32p">
  59. <BackArrowSVG />
  60. <p className="n-paragraph">Back to Blog Page</p>
  61. </a>
  62. <OneArticlesGrid>
  63. <div className="col-span-1 md:col-span-4">
  64. <BlogHeadingSection
  65. data={{
  66. ArticleImage: data[0].attributes.ArticleImage,
  67. ArticleTitle: data[0].attributes.ArticleTitle,
  68. ArticleDescription: data[0].attributes.ArticleDescription,
  69. Author: data[0].attributes.Author,
  70. AuthorTitle: data[0].attributes.AuthorTitle,
  71. AuthorImage: data[0].attributes.AuthorImage,
  72. }}
  73. />
  74. <DynamicZones data={data[0].attributes.DynamicZone1} />
  75. </div>
  76. <LatestArticles />
  77. </OneArticlesGrid>
  78. </div>
  79. </Wrapper>
  80. </div>
  81. )}
  82. </PageLayout>
  83. );
  84. }
  85. }