import { Button } from '@components/Buttons';
import { getLayout } from '@components/Layouts/Layout';
import PostHeader from '@components/PostHeader/PostHeader';
import PostsList from '@components/PostsList/PostsList';
import { config } from '@config/website';
import { t } from '@lingui/macro';
import { getPublishedPosts } from '@services/graphql/queries';
import { NextPageWithLayout } from '@ts/types/app';
import { PostsList as PostsListData } from '@ts/types/blog';
import { loadTranslation } from '@utils/helpers/i18n';
import { GetStaticProps } from 'next';
import Head from 'next/head';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import useSWRInfinite from 'swr/infinite';
import styles from '@styles/pages/Listing.module.scss';
const Search: NextPageWithLayout = () => {
  const [query, setQuery] = useState('');
  const router = useRouter();
  useEffect(() => {
    if (!router.isReady) return;
    if (router.query?.s && typeof router.query.s === 'string') {
      setQuery(router.query.s);
    }
  }, [router.isReady, router.query.s]);
  const getKey = (pageIndex: number, previousData: PostsListData) => {
    if (previousData && !previousData.posts) return null;
    return pageIndex === 0
      ? { first: config.postsPerPage, searchQuery: query }
      : {
          first: config.postsPerPage,
          after: previousData.pageInfo.endCursor,
          searchQuery: query,
        };
  };
  const { data, error, size, setSize } = useSWRInfinite(
    getKey,
    getPublishedPosts
  );
  const head = {
    title: t`Search results for ${query}] | Armand Philippot`,
    description: t`Discover search results for ${query}].`,
  };
  const isLoadingInitialData = !data && !error;
  const isLoadingMore: boolean =
    isLoadingInitialData ||
    (size > 0 && data !== undefined && typeof data[size - 1] === 'undefined');
  if (error) return 
blob: 1abf1f6c5ad29ed90a9952915cf5b64bcc7d3e78 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 | @use "@styles/abstracts/functions" as fun;
.wrapper {
  a {
    svg {
      width: 100%;
    }
    :global {
      .arrow-head {
        transform: translateY(30%) scale(1.1);
        transition: all 0.45s ease-in-out 0s;
      }
      .arrow-bar {
        opacity: 0;
        transform: translateY(30%) scaleY(0);
        transition: transform 0.4s ease-in-out 0s, opacity 0.1s linear 0.4s;
      }
    }
    &:hover,
    &:focus {
      :global {
        .arrow-head {
          transform: translateY(0) scale(1);
        }
        .arrow-bar {
          opacity: 1;
          transform: translateY(0) scaleY(1);
          transition: transform 0.45s ease-in-out 0s;
        }
      }
      svg {
        :global {
          animation: pulse 1.2s ease-in-out 0.6s infinite;
        }
      }
    }
    &:active {
      svg {
        animation-play-state: paused;
      }
    }
  }
}
 |