All files / src/pages sitemap.tsx

0% Statements 0/16
100% Branches 0/0
0% Functions 0/7
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139                                                                                                                                                                                                                                                                                     
import React from 'react';
import { Layout } from '../components';
import { graphql } from 'gatsby';
import { Helmet } from 'react-helmet';
import { useTranslation } from 'react-i18next';
import { LocalizedLink as Link } from 'gatsby-theme-i18n';
 
const Sitemap = ({ data }) => {
  const { t } = useTranslation();
  const categories = data.categories.nodes;
  const parkingProducts = data.parking.nodes;
  const experienceProducts = data.experience.nodes;
  const bicycleProducts = data.bicycle.nodes;
  const contentPages = data.contentPages.nodes;
 
  return (
    <Layout>
      <Helmet>
        <title>{`${t('content')} | ${t('sitename')}`}</title>
      </Helmet>
 
      <div style={{ padding: '1em' }}>
        <h1>{t('content')}</h1>
 
        <div>
          <h2>{t('travelBook')}</h2>
          <ul>
            <li><Link to={`/parkplatz-buchen`}>{t('parking.book')}</Link></li>
            <li><Link to={`/aktivitaeten-buchen`}>{t('experience.book')}</Link></li>
            <li><Link to={`/fahrradverleih-buchen`}>{t('bicycle.book')}</Link></li>
          </ul>
        </div>
        <div>
          <h2>{t('categories')}</h2>
          <ul>
            {categories.map(category =>
              <li key={category.strapiId}>
                <Link to={`/${category.slug}`}>{category.name}</Link>
                <ul>
                  {category.locations.map(location =>
                    <li key={location.value}>
                      <Link to={`/${category.slug}/${location.value}`}>{category.name}, {location.name}</Link>
                    </li>
                  )}
                </ul>
              </li>
            )}
          </ul>
        </div>
        <div>
          <h2>{t('checkout.products')}</h2>
          <h3>{t('parking.title')}</h3>
          <ul>
            {parkingProducts.map(product =>
              <li key={product.strapiId}>
                <Link to={`/${product.slug}`}>{product.name}</Link> &mdash; {product.location.name}
              </li>
            )}
          </ul>
          <h3>{t('experience.title')}</h3>
          <ul>
            {experienceProducts.map(product =>
              <li key={product.strapiId}>
                <Link to={`/${product.slug}`}>{product.name}</Link> &mdash; {product.location.name}
              </li>
            )}
          </ul>
          <h3>{t('bicycle.title')}</h3>
          <ul>
            {bicycleProducts.map(product =>
              <li key={product.strapiId}>
                <Link to={`/${product.slug}`}>{product.name}</Link> &mdash; {product.location.name}
              </li>
            )}
          </ul>
        </div>
        <div>
          <h2>{t('legal')}</h2>
          <ul>
            {contentPages.map(contentPage =>
              <li key={contentPage.slug}><Link to={`/${contentPage.slug}`}>{contentPage.title}</Link></li>
            )}
          </ul>
        </div>
      </div>
    </Layout>
  )
}
 
export default Sitemap;
 
export const SitemapProductData = graphql`
  fragment SitemapProductData on StrapiProduct {
    name
    strapiId
    slug
    location {
      name
    }
  }
`;
 
 
export const query = graphql`
  {
    categories: allStrapiCategory {
      nodes {
        strapiId
        name
        slug
        locations {
          name
          value
        }
      }
    }
    parking: allStrapiProduct(filter: {categories: {elemMatch: {id: {eq: 4}}}}) {
      nodes {
        ...SitemapProductData
      }
    }
    experience: allStrapiProduct(filter: {categories: {elemMatch: {id: {eq: 6}}}}) {
      nodes {
        ...SitemapProductData
      }
    }
    bicycle: allStrapiProduct(filter: {categories: {elemMatch: {id: {eq: 8}}}}) {
      nodes {
        ...SitemapProductData
      }
    }
    contentPages: allStrapiContentPage {
      nodes {
        slug
        title
      }
    }
  }
`