From a783b4a6858f25a1453d77931926ba93bc0b7052 Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Thu, 14 Dec 2023 22:39:57 +0000 Subject: Reorder news (#42) * Reslugs news items * Fixes typo in getMostRecentNewsItem() * Fixes typo in newUtils.getDate() * Sorts news index from most recent to oldest --- src/pages/[locale]/news/[...slug].astro | 23 ++++------------------- src/pages/[locale]/news/index.astro | 6 ++++-- 2 files changed, 8 insertions(+), 21 deletions(-) (limited to 'src/pages') diff --git a/src/pages/[locale]/news/[...slug].astro b/src/pages/[locale]/news/[...slug].astro index e3b8b36..a24e65a 100644 --- a/src/pages/[locale]/news/[...slug].astro +++ b/src/pages/[locale]/news/[...slug].astro @@ -1,28 +1,13 @@ --- -import locales from '$i18n/locales'; import Article from '$layouts/Article.astro'; -import type Locale from '$types/Locale'; -import { CollectionEntry, getCollection } from 'astro:content'; +import { getCollection } from 'astro:content'; +import { getLocale, getSlug } from '$lib/newsUtils'; export async function getStaticPaths() { - function localeFromSlug(slug: CollectionEntry<'news'>['slug']): Locale | undefined { - const lowerCaseLocale = new RegExp(`^(${locales.map((l) => l.toLocaleLowerCase()).join('|')})`); - const matchedLowerCaseLocale = slug.match(lowerCaseLocale)?.[1]; - switch (matchedLowerCaseLocale) { - case 'sco': - return 'sco'; - case 'en-gb': - return 'en-GB'; - default: - console.warn('Could not find locale in slug %s', slug); - return undefined; - } - } - return (await getCollection('news')).map((entry) => ({ params: { - slug: entry.slug.replace('/', '-'), - locale: localeFromSlug(entry.slug), + slug: getSlug(entry), + locale: getLocale(entry), }, props: { entry }, })); diff --git a/src/pages/[locale]/news/index.astro b/src/pages/[locale]/news/index.astro index 37e7dd6..112f87b 100644 --- a/src/pages/[locale]/news/index.astro +++ b/src/pages/[locale]/news/index.astro @@ -5,12 +5,14 @@ import Page from '$layouts/Page.astro'; import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath'; import localeStaticPaths from '$lib/localeStaticPaths'; import { getCollection } from 'astro:content'; -import { isNewsItemInLocale } from '$lib/newsUtils'; +import { isBefore, isNewsItemInLocale } from '$lib/newsUtils'; import NewsIndex from '$components/NewsIndex/NewsIndex.astro'; const allNews = await getCollection('news'); const locale = getLocaleFromPathOrThrow(Astro.url.pathname); -const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale)); +const allNewsInLocale = allNews + .filter((item) => isNewsItemInLocale(item, locale)) + .sort((a, b) => (isBefore(a, b) ? 1 : isBefore(b, a) ? -1 : 0)); const t = translate(locale); export async function getStaticPaths() { -- cgit v1.2.3 From 5d5e2f8aa5c4030c33bf06f2cb817b9d770cc884 Mon Sep 17 00:00:00 2001 From: Joe Carstairs <118172583+jcarstairs-scottlogic@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:21:30 +0000 Subject: Improve CSS reset (#51) * Font size inflation * Removes main adjustment for IE * Documents hr corrections * Documents pre corrections * Documents abbr[title] corrections * Documents b, strong corrections * Squishes pre rule with code,kbd,samp * Documents sub,sub line-height fix * Removes IE fix for img borders * Documents form control resets * Documents details display:block * Documents summary correction * Removes [hidden] fix for IE * Adds border-box sizing rules * Refactors links --- src/pages/[locale]/furthsettins/index.astro | 4 ++-- .../lallans/[issueNumber]/payment-success-confirmation.astro | 2 +- .../scotsoun/[scotsounId]/payment-success-confirmation.astro | 2 +- src/pages/[locale]/index.astro | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/pages') diff --git a/src/pages/[locale]/furthsettins/index.astro b/src/pages/[locale]/furthsettins/index.astro index 80698bd..a053621 100644 --- a/src/pages/[locale]/furthsettins/index.astro +++ b/src/pages/[locale]/furthsettins/index.astro @@ -24,13 +24,13 @@ const t = translate(locale);