Skip to content

Commit

Permalink
Use new route
Browse files Browse the repository at this point in the history
Refs #1834
  • Loading branch information
thewilkybarkid committed Dec 13, 2024
1 parent 925b10d commit fbd0c55
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
5 changes: 2 additions & 3 deletions src/AboutUsPage/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
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'
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
Expand All @@ -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',
})
}
2 changes: 1 addition & 1 deletion src/LegacyRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {}))),
Expand Down
6 changes: 2 additions & 4 deletions src/home-page/home-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -78,9 +78,7 @@ export const createPage = ({
<p>${translate(locale, 'home-page', 'overviewBetterWayText')()}</p>
<a href="${format(aboutUsMatch.formatter, {})}" class="forward"
>${translate(locale, 'home-page', 'overviewBetterWayLink')()}</a
>
<a href="${Routes.AboutUs}" class="forward">${translate(locale, 'home-page', 'overviewBetterWayLink')()}</a>
</section>
</div>
Expand Down
6 changes: 2 additions & 4 deletions src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -169,9 +169,7 @@ export const page = ({
<a href="https://content.prereview.org/">${translate(locale, 'header', 'menuBlog')()}</a>
</li>
<li>
<a
href="${format(aboutUsMatch.formatter, {})}"
${current === 'about-us' ? html`aria-current="page"` : ''}
<a href="${Routes.AboutUs}" ${current === 'about-us' ? html`aria-current="page"` : ''}
>${translate(locale, 'header', 'menuAboutUs')()}</a
>
</li>
Expand Down
2 changes: 0 additions & 2 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 2 additions & 3 deletions test/AboutUsPage/AboutUsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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(),
Expand Down

0 comments on commit fbd0c55

Please sign in to comment.