From 3433ba0aac3b266b21b06f35196a72acbce180e5 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 5 Jul 2024 11:11:57 +0300 Subject: [PATCH] page-titles --- package.json | 1 + src/components/Views/AllAuthors/AllAuthors.tsx | 16 ++++++++-------- src/context/localize.tsx | 8 +++++++- src/routes/[...slug].tsx | 7 ++++--- src/routes/author/(all).tsx | 4 ++-- src/routes/author/[slug]/[...tab].tsx | 4 ++-- src/routes/edit/{(all).tsx => (drafts).tsx} | 2 +- src/routes/edit/[id]/(draft).tsx | 2 +- src/routes/edit/[id]/settings.tsx | 3 ++- src/routes/edit/new.tsx | 2 +- src/routes/expo/[...layout].tsx | 2 +- src/routes/feed/[...feed].tsx | 2 +- src/routes/profile/(settings).tsx | 2 +- src/routes/profile/security.tsx | 2 +- src/routes/profile/subs.tsx | 2 +- src/routes/search/(search).tsx | 2 +- src/routes/topic/(all).tsx | 2 +- src/routes/topic/[...slug].tsx | 2 +- tests/page-sections.spec.ts | 2 +- 19 files changed, 38 insertions(+), 29 deletions(-) rename src/routes/edit/{(all).tsx => (drafts).tsx} (94%) diff --git a/package.json b/package.json index fdef40a1..13b2b4c5 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "build": "vinxi build", "start": "vinxi start", "codegen": "graphql-codegen", + "e2e": "npm run e2e:tests", "e2e:tests": "npx playwright test --project=webkit", "e2e:tests:ci": "CI=true npx playwright test --project=webkit", "e2e:install": "npx playwright install webkit && npx playwright install-deps ", diff --git a/src/components/Views/AllAuthors/AllAuthors.tsx b/src/components/Views/AllAuthors/AllAuthors.tsx index 622ed6f2..25cd9d9e 100644 --- a/src/components/Views/AllAuthors/AllAuthors.tsx +++ b/src/components/Views/AllAuthors/AllAuthors.tsx @@ -56,7 +56,7 @@ export const AllAuthors = (props: Props) => { }) const sortedKeys = createMemo(() => { - const keys = Object.keys(byLetterFiltered()) + const keys = Object.keys(byLetterFiltered()||{}) keys.sort() const fk = keys.shift() || '' fk && keys.push(fk) @@ -69,16 +69,16 @@ export const AllAuthors = (props: Props) => { return (
- + - - - - + + + + - - + + }>
diff --git a/src/context/localize.tsx b/src/context/localize.tsx index 5bc92718..5cc21a28 100644 --- a/src/context/localize.tsx +++ b/src/context/localize.tsx @@ -83,7 +83,13 @@ export const LocalizeProvider = (props: { children: JSX.Element }) => { const formatTimeAgo = (date: Date) => timeAgo().format(date) const value: LocalizeContextType = { - t: i18next.t, + t: ((s: string) => { + try { + return i18next.t(s) + } catch(_) { + return s + } + }) as i18n['t'], lang, setLang, formatTime, diff --git a/src/routes/[...slug].tsx b/src/routes/[...slug].tsx index cb89fc9a..57f8e5af 100644 --- a/src/routes/[...slug].tsx +++ b/src/routes/[...slug].tsx @@ -1,4 +1,4 @@ -import { RouteSectionProps, createAsync, useParams } from '@solidjs/router' +import { RouteSectionProps, createAsync, useLocation, useParams } from '@solidjs/router' import { ErrorBoundary, Suspense, createMemo, createReaction, createSignal, onMount } from 'solid-js' import { FourOuFourView } from '~/components/Views/FourOuFour' import { Loading } from '~/components/_shared/Loading' @@ -22,11 +22,12 @@ export const route = { export const ArticlePage = (props: RouteSectionProps<{ article: Shout }>) => { const params = useParams() + const loc = useLocation() const article = createAsync(async () => props.data.article || (await fetchShout(params.slug))) const { t } = useLocalize() const [scrollToComments, setScrollToComments] = createSignal(false) const title = createMemo( - () => `${article()?.authors?.[0]?.name || t('Discours')}: ${article()?.title || ''}` + () => `${article()?.authors?.[0]?.name || t('Discours')} :: ${article()?.title || ''}` ) onMount(async () => { if (gaIdentity) { @@ -49,7 +50,7 @@ export const ArticlePage = (props: RouteSectionProps<{ article: Shout }>) => { window.gtag?.('event', 'page_view', { page_title: article()?.title, page_location: window.location.href, - page_path: window.location.pathname + page_path: loc.pathname }) } }) diff --git a/src/routes/author/(all).tsx b/src/routes/author/(all).tsx index 75ec7890..55cfe50b 100644 --- a/src/routes/author/(all).tsx +++ b/src/routes/author/(all).tsx @@ -46,13 +46,13 @@ export const route = { } } satisfies RouteDefinition -export default function AllTopicsPage(props: RouteSectionProps<{ authors: Author[] }>) { +export default function AllAuthorsPage(props: RouteSectionProps<{ authors: Author[] }>) { const { t } = useLocalize() const authors = createAsync(async () => props.data.authors || (await fetchData()) || []) const { addAuthors } = useAuthors() createEffect(() => addAuthors(authors() || [])) return ( - + }> diff --git a/src/routes/author/[slug]/[...tab].tsx b/src/routes/author/[slug]/[...tab].tsx index 3695a2c2..67bf5b5d 100644 --- a/src/routes/author/[slug]/[...tab].tsx +++ b/src/routes/author/[slug]/[...tab].tsx @@ -33,7 +33,7 @@ export const TopicPage = (props: RouteSectionProps<{ articles: Shout[] }>) => { const { authorsEntities } = useAuthors() const { t } = useLocalize() const author = createMemo(() => authorsEntities?.()[params.slug]) - const title = createMemo(() => `${t('Discours')}: ${author()?.name || ''}`) + const title = createMemo(() => `${author()?.name || ''}`) // docs: `a side effect that is run the first time the expression // wrapped by the returned tracking function is notified of a change` @@ -51,7 +51,7 @@ export const TopicPage = (props: RouteSectionProps<{ articles: Shout[] }>) => { }> }> { const drafts = createAsync(async () => await fetchDrafts(client)) return ( - + diff --git a/src/routes/edit/[id]/(draft).tsx b/src/routes/edit/[id]/(draft).tsx index bc9843fc..a8b7e5ad 100644 --- a/src/routes/edit/[id]/(draft).tsx +++ b/src/routes/edit/[id]/(draft).tsx @@ -64,7 +64,7 @@ export const EditPage = () => { }) return ( - + diff --git a/src/routes/edit/[id]/settings.tsx b/src/routes/edit/[id]/settings.tsx index 1382a4c5..19519a20 100644 --- a/src/routes/edit/[id]/settings.tsx +++ b/src/routes/edit/[id]/settings.tsx @@ -25,7 +25,8 @@ export const EditSettingsPage = () => { } } return ( - + + diff --git a/src/routes/edit/new.tsx b/src/routes/edit/new.tsx index 7e2b0d46..b43fb408 100644 --- a/src/routes/edit/new.tsx +++ b/src/routes/edit/new.tsx @@ -32,7 +32,7 @@ export default () => { } } return ( - + diff --git a/src/routes/expo/[...layout].tsx b/src/routes/expo/[...layout].tsx index 9e90c8a2..e880560f 100644 --- a/src/routes/expo/[...layout].tsx +++ b/src/routes/expo/[...layout].tsx @@ -60,7 +60,7 @@ export const ExpoPage = (props: RouteSectionProps) => { createEffect(on(title, (ttl) => (document.title = ttl), { defer: true })) return ( - + diff --git a/src/routes/feed/[...feed].tsx b/src/routes/feed/[...feed].tsx index 9fc38011..6878f77a 100644 --- a/src/routes/feed/[...feed].tsx +++ b/src/routes/feed/[...feed].tsx @@ -125,7 +125,7 @@ export const FeedPage = (props: RouteSectionProps) => { } createEffect(() => setIsLoadMoreButtonVisible(offset() < (shouts()?.length || 0))) return ( - + diff --git a/src/routes/profile/(settings).tsx b/src/routes/profile/(settings).tsx index 019b31e6..8d601f7d 100644 --- a/src/routes/profile/(settings).tsx +++ b/src/routes/profile/(settings).tsx @@ -8,7 +8,7 @@ export const ProfileSettingsPage = () => { const { t } = useLocalize() return ( - + diff --git a/src/routes/profile/security.tsx b/src/routes/profile/security.tsx index b3ce6472..a00f0e1c 100644 --- a/src/routes/profile/security.tsx +++ b/src/routes/profile/security.tsx @@ -135,7 +135,7 @@ export const ProfileSecurityPage = () => { } return ( - + }>
diff --git a/src/routes/profile/subs.tsx b/src/routes/profile/subs.tsx index 075d49c9..55c44c52 100644 --- a/src/routes/profile/subs.tsx +++ b/src/routes/profile/subs.tsx @@ -7,7 +7,7 @@ export const ProfileSubscriptionsPage = () => { const { t } = useLocalize() return ( - + diff --git a/src/routes/search/(search).tsx b/src/routes/search/(search).tsx index 46e9b52d..2d95da46 100644 --- a/src/routes/search/(search).tsx +++ b/src/routes/search/(search).tsx @@ -48,7 +48,7 @@ export const SearchPage = () => { }) return ( - + }> }> diff --git a/src/routes/topic/(all).tsx b/src/routes/topic/(all).tsx index 63abb6f5..abc0e1fe 100644 --- a/src/routes/topic/(all).tsx +++ b/src/routes/topic/(all).tsx @@ -22,7 +22,7 @@ export default function AllTopicsPage(props: RouteSectionProps<{ topics: Topic[] const { addTopics } = useTopics() createEffect(() => addTopics(topics() || [])) return ( - + }> diff --git a/src/routes/topic/[...slug].tsx b/src/routes/topic/[...slug].tsx index 63e7914f..0d5566b6 100644 --- a/src/routes/topic/[...slug].tsx +++ b/src/routes/topic/[...slug].tsx @@ -33,7 +33,7 @@ export const TopicPage = (props: RouteSectionProps<{ articles: Shout[] }>) => { const { topicEntities } = useTopics() const { t } = useLocalize() const topic = createMemo(() => topicEntities?.()[params.slug]) - const title = createMemo(() => `${t('Discours')}: ${topic()?.title || ''}`) + const title = createMemo(() => `${t('Discours')} :: ${topic()?.title || ''}`) // docs: `a side effect that is run the first time the expression // wrapped by the returned tracking function is notified of a change` diff --git a/tests/page-sections.spec.ts b/tests/page-sections.spec.ts index d1a42133..f3c36901 100644 --- a/tests/page-sections.spec.ts +++ b/tests/page-sections.spec.ts @@ -69,7 +69,7 @@ test.describe('Pages open', () => { Object.keys(pagesTitles).forEach((res: string) => { test(`Open Page ${res}`, async ({ page }) => { await page.goto(`${res}`) - const title = pagesTitles[res as keyof typeof pagesTitles] || '' + const title = pagesTitles[res as keyof typeof pagesTitles] || '00000000000' await expect(page).toHaveTitle(title) }) })