From fbd0c556b0eaec6dadb457304f26c4c944f0b5a3 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Fri, 13 Dec 2024 14:48:11 +0000 Subject: [PATCH] Use new route Refs #1834 --- src/AboutUsPage/index.ts | 5 ++--- src/LegacyRouter.ts | 2 +- src/home-page/home-page.ts | 6 ++---- src/page.ts | 6 ++---- src/routes.ts | 2 -- test/AboutUsPage/AboutUsPage.test.ts | 5 ++--- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/AboutUsPage/index.ts b/src/AboutUsPage/index.ts index c6a5ec07f..72ae11b99 100644 --- a/src/AboutUsPage/index.ts +++ b/src/AboutUsPage/index.ts @@ -1,6 +1,5 @@ import { FetchHttpClient } from '@effect/platform' import { Effect } from 'effect' -import { format } from 'fp-ts-routing' import { DeprecatedSleepEnv, Locale } from '../Context.js' import * as FptsToEffect from '../FptsToEffect.js' import { getPage, GhostApi } from '../ghost.js' @@ -8,7 +7,7 @@ import { HavingProblemsPage } from '../HavingProblemsPage/index.js' import { type Html, fixHeadingLevels, html, plainText } from '../html.js' import { type SupportedLocale, translate } from '../locales/index.js' import { PageResponse } from '../response.js' -import { aboutUsMatch } from '../routes.js' +import * as Routes from '../routes.js' export const AboutUsPage = Effect.gen(function* () { const locale = yield* Locale @@ -35,7 +34,7 @@ function createPage({ content, locale }: { content: Html; locale: SupportedLocal ${fixHeadingLevels(1, content)} `, - canonical: format(aboutUsMatch.formatter, {}), + canonical: Routes.AboutUs, current: 'about-us', }) } diff --git a/src/LegacyRouter.ts b/src/LegacyRouter.ts index 6c3aeadd0..abf0a3ea5 100644 --- a/src/LegacyRouter.ts +++ b/src/LegacyRouter.ts @@ -42,7 +42,7 @@ export const LegacyRouter = HttpRouter.empty HttpRouter.all('/blog', movedPermanently('https://content.prereview.org/')), HttpRouter.all('/coc', movedPermanently(format(Routes.codeOfConductMatch.formatter, {}))), HttpRouter.all('/communities', movedPermanently(format(Routes.clubsMatch.formatter, {}))), - HttpRouter.all('/docs/about', movedPermanently(format(Routes.aboutUsMatch.formatter, {}))), + HttpRouter.all('/docs/about', movedPermanently(Routes.AboutUs)), HttpRouter.all('/docs/codeofconduct', movedPermanently(format(Routes.codeOfConductMatch.formatter, {}))), HttpRouter.all('/docs/code_of_conduct', movedPermanently(format(Routes.codeOfConductMatch.formatter, {}))), HttpRouter.all('/docs/resources', movedPermanently(format(Routes.resourcesMatch.formatter, {}))), diff --git a/src/home-page/home-page.ts b/src/home-page/home-page.ts index 5430d8f41..b7fd4c865 100644 --- a/src/home-page/home-page.ts +++ b/src/home-page/home-page.ts @@ -9,8 +9,8 @@ import { type Html, html, plainText, rawHtml } from '../html.js' import { type SupportedLocale, translate } from '../locales/index.js' import assets from '../manifest.json' with { type: 'json' } import { PageResponse } from '../response.js' +import * as Routes from '../routes.js' import { - aboutUsMatch, homeMatch, requestAPrereviewMatch, reviewAPreprintMatch, @@ -78,9 +78,7 @@ export const createPage = ({

${translate(locale, 'home-page', 'overviewBetterWayText')()}

- ${translate(locale, 'home-page', 'overviewBetterWayLink')()} + ${translate(locale, 'home-page', 'overviewBetterWayLink')()} diff --git a/src/page.ts b/src/page.ts index a63437dd6..c401dd262 100644 --- a/src/page.ts +++ b/src/page.ts @@ -6,8 +6,8 @@ import { match } from 'ts-pattern' import { type Html, type PlainText, html, rawHtml } from './html.js' import { DefaultLocale, type SupportedLocale, UserSelectableLocales, translate } from './locales/index.js' import assets from './manifest.json' with { type: 'json' } +import * as Routes from './routes.js' import { - aboutUsMatch, clubsMatch, codeOfConductMatch, ediaStatementMatch, @@ -169,9 +169,7 @@ export const page = ({ ${translate(locale, 'header', 'menuBlog')()}
  • - ${translate(locale, 'header', 'menuAboutUs')()}
  • diff --git a/src/routes.ts b/src/routes.ts index 16d609ad1..19436b494 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -208,8 +208,6 @@ const PreprintIdC = C.make(D.union(PreprintDoiC, PreprintPhilsciC), { export const homeMatch = pipe(query(C.partial({})), P.then(P.end)) -export const aboutUsMatch = pipe(P.lit('about'), P.then(P.end)) - export const peopleMatch = pipe(P.lit('people'), P.then(P.end)) export const howToUseMatch = pipe(P.lit('how-to-use'), P.then(P.end)) diff --git a/test/AboutUsPage/AboutUsPage.test.ts b/test/AboutUsPage/AboutUsPage.test.ts index d25a16d3c..f49e8f78b 100644 --- a/test/AboutUsPage/AboutUsPage.test.ts +++ b/test/AboutUsPage/AboutUsPage.test.ts @@ -3,12 +3,11 @@ import { test } from '@fast-check/jest' import { describe, expect } from '@jest/globals' import { Effect, pipe, TestContext } from 'effect' import fetchMock from 'fetch-mock' -import { format } from 'fp-ts-routing' import { Status } from 'hyper-ts' import * as _ from '../../src/AboutUsPage/index.js' import { DeprecatedSleepEnv, Locale } from '../../src/Context.js' import { GhostApi } from '../../src/ghost.js' -import { aboutUsMatch } from '../../src/routes.js' +import * as Routes from '../../src/routes.js' import * as fc from '../fc.js' import { shouldNotBeCalled } from '../should-not-be-called.js' @@ -32,7 +31,7 @@ describe('AboutUsPage', () => { expect(actual).toStrictEqual({ _tag: 'PageResponse', - canonical: format(aboutUsMatch.formatter, {}), + canonical: Routes.AboutUs, current: 'about-us', status: Status.OK, title: expect.anything(),