import Layout from '../components/Layout'; import styled from '@emotion/styled'; import { Grid } from '@theme-ui/components'; import { useEffect, useRef, useState } from 'react'; import MetaContent from '../components/Page/metaContent'; import { Container } from '../components/Container'; import { Card, CardDetail, CardGraphic } from '../components/Card'; import { filterOptionsByName, filterMetadataByOption } from '../utils/filter-data'; import { getChapterDirectory, getProductDirectory, isProductRoot } from '../utils/getLocalDirectory'; const H3 = styled.h3` margin-top: 0.375rem; font-size: 1.715rem; line-height: 2.75rem; font-weight: 400; margin-bottom: 1.5rem; `; function ChooseFilterPage({ directoryPath, address, filterKind, filters = [], currentFilter = 'all', message = '' }) { // "url" cannot be a CFP prop for legacy reasons let url = address; const [_, setHref] = useState('https://docs.amplify.aws'); const [menuIsOpen, setMenuIsOpen] = useState(false); const footerRef = useRef(null); useEffect(() => { setHref(window.location.href); }, []); url = url.split('/q/')[0]; let title = '', chapterTitle = ''; if (isProductRoot(url)) { title = (getProductDirectory(url) as { productRoot: { title: string }; }).productRoot.title; } else { const chapterDirectory = getChapterDirectory(url); if (typeof chapterDirectory !== 'undefined') { const { title: cTitle, items } = chapterDirectory as { title: string; items: { route: string; title: string }[]; }; chapterTitle = cTitle; for (const item of items) { if (item.route === url) title = item.title; } } } if (filters.length === 0) filters = filterOptionsByName[filterKind]; const children = (
{message &&

{message}

} {filters.map((filter) => (

{filterMetadataByOption[filter].label}

))}
); return ( ); } ChooseFilterPage.getInitialProps = (initialProps) => { return initialProps.query; }; export default ChooseFilterPage;