diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-14 17:16:53 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-14 17:30:37 +0100 |
| commit | 916c512bf5a31041ac87296e1382f84c9367b955 (patch) | |
| tree | 9541124a1339ce6e12f46983fce875b41d1fff00 /src/components/Widgets/ThematicsList/ThematicsList.tsx | |
| parent | 79f7688703fe42ce87c92567f5bc92b6691eaa20 (diff) | |
chore: display initial posts, thematics & topics
By fetching the data in getStaticProps, I can display the data even
for users with Javascript disabled.
Diffstat (limited to 'src/components/Widgets/ThematicsList/ThematicsList.tsx')
| -rw-r--r-- | src/components/Widgets/ThematicsList/ThematicsList.tsx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/components/Widgets/ThematicsList/ThematicsList.tsx b/src/components/Widgets/ThematicsList/ThematicsList.tsx index f175e80..f50a069 100644 --- a/src/components/Widgets/ThematicsList/ThematicsList.tsx +++ b/src/components/Widgets/ThematicsList/ThematicsList.tsx @@ -2,6 +2,7 @@ import Spinner from '@components/Spinner/Spinner'; import { ExpandableWidget, List } from '@components/WidgetParts'; import { getAllThematics } from '@services/graphql/queries'; import { TitleLevel } from '@ts/types/app'; +import { ThematicPreview } from '@ts/types/taxonomies'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { useIntl } from 'react-intl'; @@ -10,9 +11,11 @@ import useSWR from 'swr'; const ThematicsList = ({ title, titleLevel, + initialData, }: { title: string; titleLevel?: TitleLevel; + initialData?: ThematicPreview[]; }) => { const intl = useIntl(); const router = useRouter(); @@ -21,7 +24,9 @@ const ThematicsList = ({ ? router.asPath.replace('/thematique/', '') : ''; - const { data, error } = useSWR('/api/thematics', getAllThematics); + const { data, error } = useSWR('/api/thematics', getAllThematics, { + fallbackData: initialData, + }); const getList = () => { if (error) @@ -62,12 +67,6 @@ const ThematicsList = ({ withBorders={true} expand={true} > - <noscript> - {intl.formatMessage({ - defaultMessage: 'Javascript is required to load the thematics.', - description: 'ThematicsList: noscript tag', - })} - </noscript> {getList()} </ExpandableWidget> ); |
