diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-29 12:28:03 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-29 13:47:07 +0100 |
| commit | dfa894b76ee3584bf169710c78c57330c5d6ee67 (patch) | |
| tree | 41380a93e2838452236a720f27f85fb14502f56a /src/pages | |
| parent | 29a1dec4de0aa7ba64ef068a83b1b8589fbc3ad0 (diff) | |
fix(pages,services): make thematics & topics pages usable again
When I refactored the fetchers and convertors in #f111685 I forgot to
convert WPThematicPreview and WPTopicPreview so the thematics and
topics pages was broken.
I also:
* removed the ToC added by error in #70b4f63
* fix heading styles
* fix website url in topics pages
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/404.tsx | 11 | ||||
| -rw-r--r-- | src/pages/blog/index.tsx | 11 | ||||
| -rw-r--r-- | src/pages/blog/page/[number].tsx | 11 | ||||
| -rw-r--r-- | src/pages/recherche/index.tsx | 11 | ||||
| -rw-r--r-- | src/pages/sujet/[slug].tsx | 32 | ||||
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 32 |
6 files changed, 54 insertions, 54 deletions
diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 5f4f89d..a98931f 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -18,7 +18,8 @@ import { type SearchFormSubmit, } from '../components'; import { - convertTaxonomyToPageLink, + convertWPThematicPreviewToPageLink, + convertWPTopicPreviewToPageLink, fetchThematicsCount, fetchThematicsList, fetchTopicsCount, @@ -147,7 +148,9 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ {thematicsListTitle} </Heading> } - items={getLinksItemData(thematicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + thematicsList.map(convertWPThematicPreviewToPageLink) + )} /> <LinksWidget heading={ @@ -155,7 +158,9 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ {topicsListTitle} </Heading> } - items={getLinksItemData(topicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + topicsList.map(convertWPTopicPreviewToPageLink) + )} /> </PageSidebar> </Page> diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx index 56cbb02..12bc03e 100644 --- a/src/pages/blog/index.tsx +++ b/src/pages/blog/index.tsx @@ -20,7 +20,8 @@ import { PageSidebar, } from '../../components'; import { - convertTaxonomyToPageLink, + convertWPThematicPreviewToPageLink, + convertWPTopicPreviewToPageLink, fetchPostsCount, fetchPostsList, fetchThematicsCount, @@ -265,7 +266,9 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ {thematicsListTitle} </Heading> } - items={getLinksItemData(thematicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + thematicsList.map(convertWPThematicPreviewToPageLink) + )} /> <LinksWidget heading={ @@ -273,7 +276,9 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ {topicsListTitle} </Heading> } - items={getLinksItemData(topicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + topicsList.map(convertWPTopicPreviewToPageLink) + )} /> </PageSidebar> </Page> diff --git a/src/pages/blog/page/[number].tsx b/src/pages/blog/page/[number].tsx index d6071d1..35d4bad 100644 --- a/src/pages/blog/page/[number].tsx +++ b/src/pages/blog/page/[number].tsx @@ -20,7 +20,8 @@ import { PageSidebar, } from '../../../components'; import { - convertTaxonomyToPageLink, + convertWPThematicPreviewToPageLink, + convertWPTopicPreviewToPageLink, fetchLastPostCursor, fetchPostsCount, fetchPostsList, @@ -247,7 +248,9 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ {thematicsListTitle} </Heading> } - items={getLinksItemData(thematicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + thematicsList.map(convertWPThematicPreviewToPageLink) + )} /> <LinksWidget heading={ @@ -255,7 +258,9 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({ {topicsListTitle} </Heading> } - items={getLinksItemData(topicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + topicsList.map(convertWPTopicPreviewToPageLink) + )} /> </PageSidebar> </Page> diff --git a/src/pages/recherche/index.tsx b/src/pages/recherche/index.tsx index 293df0e..bb3aa53 100644 --- a/src/pages/recherche/index.tsx +++ b/src/pages/recherche/index.tsx @@ -20,7 +20,8 @@ import { PageBody, } from '../../components'; import { - convertTaxonomyToPageLink, + convertWPThematicPreviewToPageLink, + convertWPTopicPreviewToPageLink, fetchPostsCount, fetchPostsList, fetchThematicsCount, @@ -253,7 +254,9 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ {thematicsListTitle} </Heading> } - items={getLinksItemData(thematicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + thematicsList.map(convertWPThematicPreviewToPageLink) + )} /> <LinksWidget heading={ @@ -261,7 +264,9 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ {topicsListTitle} </Heading> } - items={getLinksItemData(topicsList.map(convertTaxonomyToPageLink))} + items={getLinksItemData( + topicsList.map(convertWPTopicPreviewToPageLink) + )} /> </PageSidebar> </Page> diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index c63906f..483df48 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -14,11 +14,11 @@ import { Page, PageHeader, PageSidebar, - TocWidget, PageBody, } from '../../components'; import { - convertTaxonomyToPageLink, + convertWPTopicPreviewToPageLink, + convertWPTopicToTopic, fetchAllTopicsSlugs, fetchTopic, fetchTopicsCount, @@ -36,7 +36,7 @@ import { getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; -import { useBreadcrumb, useHeadingsTree } from '../../utils/hooks'; +import { useBreadcrumb } from '../../utils/hooks'; export type TopicPageProps = { currentTopic: Topic; @@ -54,7 +54,7 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ cover, dates, seo, - thematics, + relatedThematics, website: officialWebsite, } = meta; const intl = useIntl(); @@ -62,7 +62,6 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ title, url: `${ROUTES.TOPICS}/${slug}`, }); - const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ @@ -103,11 +102,6 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ </> ); const pageUrl = `${CONFIG.url}${asPath}`; - const tocTitle = intl.formatMessage({ - defaultMessage: 'Table of Contents', - description: 'PageLayout: table of contents title', - id: 'eys2uX', - }); return ( <Page breadcrumbs={breadcrumbItems}> @@ -144,13 +138,7 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ website: officialWebsite, }} /> - <PageSidebar> - <TocWidget - heading={<Heading level={3}>{tocTitle}</Heading>} - tree={tree} - /> - </PageSidebar> - <PageBody className={styles.body} ref={ref}> + <PageBody className={styles.body}> {/*eslint-disable-next-line react/no-danger -- Necessary for content*/} {content ? <div dangerouslySetInnerHTML={{ __html: content }} /> : null} {articles ? ( @@ -175,14 +163,14 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ ) : null} </PageBody> <PageSidebar> - {thematics ? ( + {relatedThematics ? ( <LinksWidget heading={ <Heading isFake level={3}> {thematicsListTitle} </Heading> } - items={getLinksItemData(thematics)} + items={getLinksItemData(relatedThematics)} /> ) : null} <LinksWidget @@ -214,7 +202,7 @@ export const getStaticProps: GetStaticProps<TopicPageProps> = async ({ first: totalTopics, }); const allTopics = allTopicsEdges.edges.map((edge) => - convertTaxonomyToPageLink(edge.node) + convertWPTopicPreviewToPageLink(edge.node) ); const topicsLinks = allTopics.filter( (topic) => topic.url !== `${ROUTES.TOPICS}/${(params as TopicParams).slug}` @@ -223,7 +211,9 @@ export const getStaticProps: GetStaticProps<TopicPageProps> = async ({ return { props: { - currentTopic: JSON.parse(JSON.stringify(currentTopic)), + currentTopic: JSON.parse( + JSON.stringify(convertWPTopicToTopic(currentTopic)) + ), topics: JSON.parse(JSON.stringify(topicsLinks)), translation, }, diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index f8c3404..9ea52e1 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -13,11 +13,11 @@ import { Page, PageHeader, PageSidebar, - TocWidget, PageBody, } from '../../components'; import { - convertTaxonomyToPageLink, + convertWPThematicPreviewToPageLink, + convertWPThematicToThematic, fetchAllThematicsSlugs, fetchThematic, fetchThematicsCount, @@ -35,7 +35,7 @@ import { getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; -import { useBreadcrumb, useHeadingsTree } from '../../utils/hooks'; +import { useBreadcrumb } from '../../utils/hooks'; export type ThematicPageProps = { currentThematic: Thematic; @@ -48,13 +48,12 @@ const ThematicPage: NextPageWithLayout<ThematicPageProps> = ({ thematics, }) => { const { content, intro, meta, slug, title } = currentThematic; - const { articles, dates, seo, topics } = meta; + const { articles, dates, seo, relatedTopics } = meta; const intl = useIntl(); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, url: `${ROUTES.THEMATICS.INDEX}/${slug}`, }); - const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ @@ -87,11 +86,6 @@ const ThematicPage: NextPageWithLayout<ThematicPageProps> = ({ id: '/42Z0z', }); const pageUrl = `${CONFIG.url}${asPath}`; - const tocTitle = intl.formatMessage({ - defaultMessage: 'Table of Contents', - description: 'PageLayout: table of contents title', - id: 'eys2uX', - }); return ( <Page breadcrumbs={breadcrumbItems}> @@ -127,13 +121,7 @@ const ThematicPage: NextPageWithLayout<ThematicPageProps> = ({ updateDate: dates.update, }} /> - <PageSidebar> - <TocWidget - heading={<Heading level={3}>{tocTitle}</Heading>} - tree={tree} - /> - </PageSidebar> - <PageBody className={styles.body} ref={ref}> + <PageBody className={styles.body}> {/*eslint-disable-next-line react/no-danger -- Necessary for content*/} <div dangerouslySetInnerHTML={{ __html: content }} /> {articles ? ( @@ -166,14 +154,14 @@ const ThematicPage: NextPageWithLayout<ThematicPageProps> = ({ } items={getLinksItemData(thematics)} /> - {topics ? ( + {relatedTopics ? ( <LinksWidget heading={ <Heading isFake level={3}> {topicsListTitle} </Heading> } - items={getLinksItemData(topics)} + items={getLinksItemData(relatedTopics)} /> ) : null} </PageSidebar> @@ -197,7 +185,7 @@ export const getStaticProps: GetStaticProps<ThematicPageProps> = async ({ first: totalThematics, }); const allThematics = allThematicsEdges.edges.map((edge) => - convertTaxonomyToPageLink(edge.node) + convertWPThematicPreviewToPageLink(edge.node) ); const allThematicsLinks = allThematics.filter( (thematic) => @@ -208,7 +196,9 @@ export const getStaticProps: GetStaticProps<ThematicPageProps> = async ({ return { props: { - currentThematic: JSON.parse(JSON.stringify(currentThematic)), + currentThematic: JSON.parse( + JSON.stringify(convertWPThematicToThematic(currentThematic)) + ), thematics: JSON.parse(JSON.stringify(allThematicsLinks)), translation, }, |
