diff --git a/src/response.ts b/src/response.ts index 3927070df..1dd7d8753 100644 --- a/src/response.ts +++ b/src/response.ts @@ -35,12 +35,12 @@ export interface PageResponse { readonly canonical?: string readonly current?: Page['current'] readonly status: Status - readonly title: Page['title'] | ((lang: SupportedLocale) => Page['title']) - readonly description?: Page['description'] | ((lang: SupportedLocale) => Page['description']) - readonly nav?: Html | ((lang: SupportedLocale) => Html) - readonly main: Html | ((lang: SupportedLocale) => Html) + readonly title: Page['title'] + readonly description?: Page['description'] + readonly nav?: Html + readonly main: Html readonly skipToLabel: 'form' | 'main' | 'prereview' - readonly extraSkipLink?: [Html, string] | ((lang: SupportedLocale) => [Html, string]) + readonly extraSkipLink?: [Html, string] readonly js: Required['js'] } @@ -49,10 +49,10 @@ export interface StreamlinePageResponse { readonly canonical?: string readonly current?: Page['current'] readonly status: Status - readonly title: Page['title'] | ((lang: SupportedLocale) => Page['title']) - readonly description?: Page['description'] | ((lang: SupportedLocale) => Page['description']) - readonly nav?: Html | ((lang: SupportedLocale) => Html) - readonly main: Html | ((lang: SupportedLocale) => Html) + readonly title: Page['title'] + readonly description?: Page['description'] + readonly nav?: Html + readonly main: Html readonly skipToLabel: 'form' | 'main' readonly js: Required['js'] readonly allowRobots?: false @@ -61,11 +61,11 @@ export interface StreamlinePageResponse { export interface TwoUpPageResponse { readonly _tag: 'TwoUpPageResponse' readonly canonical: string - readonly title: Page['title'] | ((lang: SupportedLocale) => Page['title']) - readonly description?: Page['description'] | ((lang: SupportedLocale) => Page['description']) - readonly h1: Html | ((lang: SupportedLocale) => Html) - readonly aside: Html | ((lang: SupportedLocale) => Html) - readonly main: Html | ((lang: SupportedLocale) => Html) + readonly title: Page['title'] + readonly description?: Page['description'] + readonly h1: Html + readonly aside: Html + readonly main: Html } export interface RedirectResponse { @@ -199,25 +199,18 @@ export const handlePageResponse = ({ templatePage({ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition locale: locale !== DefaultLocale ? locale : undefined, - title: typeof response.title === 'function' ? response.title(locale) : response.title, - description: typeof response.description === 'function' ? response.description(locale) : response.description, + title: response.title, + description: response.description, content: html` - ${response.nav - ? html` ` - : ''} + ${response.nav ? html` ` : ''}
- ${message ? showFlashMessage(message, locale) : ''} - ${typeof response.main === 'function' ? response.main(locale) : response.main} + ${message ? showFlashMessage(message, locale) : ''} ${response.main}
`, skipLinks: [ [rawHtml(translate(locale, 'skip-links', response.skipToLabel)()), `#${response.skipToLabel}`], - ...(response._tag === 'PageResponse' && response.extraSkipLink - ? typeof response.extraSkipLink === 'function' - ? [response.extraSkipLink(locale)] - : [response.extraSkipLink] - : []), + ...(response._tag === 'PageResponse' && response.extraSkipLink ? [response.extraSkipLink] : []), ], current: response.current, js: response.js.concat(...(message ? (['notification-banner.js'] as const) : [])), @@ -288,19 +281,14 @@ const handleTwoUpPageResponse = ({ templatePage({ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition locale: locale !== DefaultLocale ? locale : undefined, - title: typeof response.title === 'function' ? response.title(locale) : response.title, - description: typeof response.description === 'function' ? response.description(locale) : response.description, + title: response.title, + description: response.description, content: html` -

${typeof response.h1 === 'function' ? response.h1(locale) : response.h1}

+

${response.h1}

- + -
- ${message ? showFlashMessage(message, locale) : ''} - ${typeof response.main === 'function' ? response.main(locale) : response.main} -
+
${message ? showFlashMessage(message, locale) : ''} ${response.main}
`, skipLinks: [ [html`Skip to preprint details`, '#preprint-details'], diff --git a/visual-regression/base.ts b/visual-regression/base.ts index 430144c78..351ce545a 100644 --- a/visual-regression/base.ts +++ b/visual-regression/base.ts @@ -2,7 +2,6 @@ import { type Locator, test as baseTest } from '@playwright/test' import path from 'path' import { P, match } from 'ts-pattern' import { type Html, html } from '../src/html.js' -import { DefaultLocale } from '../src/locales/index.js' import { type Page, page as templatePage } from '../src/page.js' import type { PageResponse, StreamlinePageResponse, TwoUpPageResponse } from '../src/response.js' @@ -46,19 +45,15 @@ export const test = baseTest.extend({ showPage: async ({ page, showHtml, templatePage }, use) => { await use(async function showPage(response, extra = {}) { const content = html` - ${response.nav - ? html` ` - : ''} + ${response.nav ? html` ` : ''} -
- ${typeof response.main === 'function' ? response.main(DefaultLocale) : response.main} -
+
${response.main}
` const pageHtml = templatePage({ ...extra, content, - title: typeof response.title === 'function' ? response.title(DefaultLocale) : response.title, + title: response.title, js: response.js, }) @@ -70,20 +65,16 @@ export const test = baseTest.extend({ showTwoUpPage: async ({ page, showHtml, templatePage }, use) => { await use(async response => { const content = html` -

${typeof response.h1 === 'function' ? response.h1(DefaultLocale) : response.h1}

+

${response.h1}

- + -
- ${typeof response.main === 'function' ? response.main(DefaultLocale) : response.main} -
+
${response.main}
` const pageHtml = templatePage({ content, - title: typeof response.title === 'function' ? response.title(DefaultLocale) : response.title, + title: response.title, type: 'two-up', })