summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2023-08-15 19:15:27 +0100
committerJoe Carstairs <jcarstairs@scottlogic.com>2023-08-15 19:15:27 +0100
commit53f29bac911b13b2bef0125de22773bf26ce5a90 (patch)
treee4dad6d88e2fe4c4eda8ff286db50d9a6f561242 /src
parent8b009f0ea6ea9d181ba8d0e6549c25645aa697c4 (diff)
Adds homepage
Diffstat (limited to 'src')
-rw-r--r--src/data/contactDetails.ts8
-rw-r--r--src/i18n/translations/pages/home.ts110
-rw-r--r--src/i18n/translations/site.ts4
-rw-r--r--src/lib/newsUtils.ts35
-rw-r--r--src/pages/[locale]/index.astro95
-rw-r--r--src/pages/[locale]/news/index.astro9
6 files changed, 213 insertions, 48 deletions
diff --git a/src/data/contactDetails.ts b/src/data/contactDetails.ts
new file mode 100644
index 0000000..f5de6f5
--- /dev/null
+++ b/src/data/contactDetails.ts
@@ -0,0 +1,8 @@
+export default {
+ membershipSecretary: {
+ emailAddress: 'lallans@hotmail.co.uk',
+ },
+ generalEnquiries: {
+ emailAddress: 'lallans@hotmail.co.uk',
+ },
+};
diff --git a/src/i18n/translations/pages/home.ts b/src/i18n/translations/pages/home.ts
index 635b33a..302d643 100644
--- a/src/i18n/translations/pages/home.ts
+++ b/src/i18n/translations/pages/home.ts
@@ -5,6 +5,116 @@ const tPage = {
sco: () => 'Hame',
'en-GB': () => 'Home',
},
+ news: {
+ sco: () => 'Recent News',
+ 'en-GB': () => 'Recent News',
+ },
+ 'aw-news': {
+ sco: () => 'Aw news',
+ 'en-GB': () => 'All news',
+ },
+ furthsettins: {
+ sco: () => 'Furthsettins',
+ 'en-GB': () => 'Publications',
+ },
+ 'furthsettins-para': {
+ sco: () => `
+ We ar ane o the foremaist furthsetters o new Scots leitratur.
+ Oor maist important furthsettins ar
+ <a href="/sco/furthsettins/lallans" class="link">Lallans</a> an
+ <a href="/sco/furthsettins/scotsoun" class="link">Scotsoun</a>.
+ `,
+ 'en-GB': () => `
+ We are one of the leading publishers of new Scots literature.
+ Our most important publications are
+ <a href="/en-GB/furthsettins/lallans" class="link">Lallans</a> and
+ <a href="/en-GB/furthsettins/scotsoun" class="link">Scotsoun</a>.
+ `,
+ },
+ 'aw-furthsettins': {
+ sco: () => 'Aw furthsettins',
+ 'en-GB': () => 'All publications',
+ },
+ jyne: {
+ sco: () => 'Jyne',
+ 'en-GB': () => 'Join',
+ },
+ 'why-jyne': {
+ sco: () => 'Why jyne the Scots Leid Associe?',
+ 'en-GB': () => 'Why join the Scots Language Society?',
+ },
+ 'why-jyne-para-1': {
+ sco: () => `
+ Bi jynin us, ye ar helpin us tae heize up the Scots leid, maistly bi giein
+ Scots scrievers a place tae lairn frae anither an finnd their ain Scots vyce.
+ `,
+ 'en-GB': () => `
+ By joining us, you are helping us to champion the Scots language,
+ especially by giving Scots writers a place to learn from one
+ another and to find their own Scots voice.
+ `,
+ },
+ 'why-jyne-para-2': {
+ sco: () => `
+ Forby, memmers get biannual issues o our aesome <i>Lallans</i> magazine gratis,
+ an hae the richt tae atten our Annual Collogues, whaur we haud our AGM an
+ enjoy talks frae kenspeckle spikkers on thochtie maiters effeirin til Scots
+ leid an leiteratur.
+ `,
+ 'en-GB': () => `
+ In addition, members get biannual issues of our unique <i>Lallans</i>
+ magazine gratis, and have the right to attend our Annual Conferences, where
+ we hold our AGM and enjoy talks from highly regarded speakers on
+ thought-provoking subjects relating to Scots language and literature.
+ `,
+ },
+ 'why-jyne-para-3': {
+ sco: () => `
+ Gin whit ye ar seekin is a community o prose-scrievers, makars, pleywreichts
+ an owersetters, aw wi muckle care fur the Scots leid, the ar nae peer wi hus,
+ the auldest Scots-leid activist organisation that’s about eenou an the anely
+ fully dedicatit til the forderance o new Scots leiteratur.
+ `,
+ 'en-GB': () => `
+ If what you’re looking for is a community of prose-writers, poets,
+ playwrights and translators with a passion for the Scots language, we have
+ no equal. We are the oldest extant Scots-language activist organisation and
+ the only one solely dedicated to the development of new Scots literature.
+ `,
+ },
+ 'hou-jyne': {
+ sco: () => 'Hou can A jyne?',
+ 'en-GB': () => 'How can I join?',
+ },
+ 'hou-jyne-para-1': {
+ sco: () => `
+ Fur individuals, memmership costs £20 per annum. Fur aw ithers, the stent is £25 per annum.
+ `,
+ 'en-GB': () => `
+ For individuals, membership costs £20 per annum. For all others, the fee is £25 per annum.
+ `,
+ },
+ 'hou-jyne-para-2': {
+ sco: ({ membershipEmail }: { membershipEmail: string }) => `
+ Fur tae become a memmer, simply get in titch wi us at
+ <a class="link" href="mailto:${membershipEmail}">${membershipEmail}</a>
+ an we’ll provide ye wi our bank details; or ye can jyne bi sendin us a cheque
+ made peyable til <b>The Scots Language Society</b>. See
+ <a class="link" href="#contact">Contact us</a>
+ fur our address.
+ `,
+ 'en-GB': ({ membershipEmail }: { membershipEmail: string }) => `
+ To become a member, simply get in touch with us at
+ <a class="link" href="mailto:${membershipEmail}">${membershipEmail}</a>
+ and we’ll provide you with our bank details; or you can join by sending us
+ a cheque made payable to <b>The Scots Language Society</b>. See
+ <a class="link" href="#contact">Contact us</a> for our address.
+ `,
+ },
+ contact: {
+ sco: () => 'Contact us',
+ 'en-GB': () => 'Contact us',
+ },
};
type Raw = typeof tPage;
diff --git a/src/i18n/translations/site.ts b/src/i18n/translations/site.ts
index 5c18786..95b7f8e 100644
--- a/src/i18n/translations/site.ts
+++ b/src/i18n/translations/site.ts
@@ -29,6 +29,10 @@ const tSite = {
sco: () => 'bi',
'en-GB': () => 'by',
},
+ and: {
+ sco: () => 'an',
+ 'en-GB': () => 'and',
+ },
locale: {
sco: ({ locale }: { locale: Locale }) => {
switch (locale) {
diff --git a/src/lib/newsUtils.ts b/src/lib/newsUtils.ts
new file mode 100644
index 0000000..ededb52
--- /dev/null
+++ b/src/lib/newsUtils.ts
@@ -0,0 +1,35 @@
+import type Locale from '$types/Locale';
+import { CollectionEntry, getCollection } from 'astro:content';
+
+export async function getMostRecentNewsItem(locale: Locale) {
+ const allNews = await getCollection('news');
+ const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale));
+ const someNewsItem = allNewsInLocale.at(0);
+ if (!someNewsItem) {
+ return null;
+ }
+ return allNewsInLocale.reduce((prev, curr) => (isBefore(curr, prev) ? curr : prev), someNewsItem);
+}
+
+export function isNewsItemInLocale(newsItem: CollectionEntry<'news'>, locale: Locale) {
+ const srcPath = newsItem.id;
+ const newsItemLocale = srcPath.slice(0, srcPath.indexOf('/'));
+ return newsItemLocale === locale;
+}
+
+function isBefore(item1: CollectionEntry<'news'>, item2: CollectionEntry<'news'>) {
+ const date1 = dateOf(item1);
+ const date2 = dateOf(item2);
+ if (!date2) {
+ return false;
+ }
+ if (!date1) {
+ return true;
+ }
+ return date1.valueOf() < date2.valueOf();
+}
+
+function dateOf(newsItem: CollectionEntry<'news'>) {
+ const match = newsItem.id.match(/(?<=(en-GB|sco))\/(\d\d\d\d-\d\d-\d\d)/)?.[2];
+ return match ? new Date(match) : null;
+}
diff --git a/src/pages/[locale]/index.astro b/src/pages/[locale]/index.astro
index c32ddf6..3674b9f 100644
--- a/src/pages/[locale]/index.astro
+++ b/src/pages/[locale]/index.astro
@@ -2,9 +2,11 @@
import Page from '$layouts/Page.astro';
import localeStaticPaths from '$lib/localeStaticPaths';
import translate from '$i18n/translate';
-import site from '$i18n/translations/site';
-import home from '$i18n/translations/pages/home';
+import tPage from '$i18n/translations/pages/home';
import type Locale from '$types/Locale';
+import { getMostRecentNewsItem } from '$lib/newsUtils';
+import NewsPreviewLink from '$components/NewsPreviewLink.astro';
+import contactDetails from '$data/contactDetails';
export async function getStaticPaths() {
return localeStaticPaths;
@@ -12,49 +14,60 @@ export async function getStaticPaths() {
const locale = Astro.params.locale as Locale;
const t = translate(locale);
+const mostRecentNewsItem = await getMostRecentNewsItem(locale);
---
-<Page title={t(home, { key: 'title' })}>
+<Page title={t(tPage, { key: 'title' })}>
<section>
- <h1 class="title">{t(site, { key: 'title' })}</h1>
- <h1>Tap-level heidin</h1>
- <h2>Seicont-level heidin</h2>
- <h3>Third-level heidin</h3>
- <h4>Fowert-level heidin</h4>
- <p>
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
- labore et dolore magna aliqua.
- </p>
- <a class="link" href="#">Lairn mair!</a>
- <p>
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
- commodo consequat.
- </p>
- <button class="btn">Dae somethin excitin...</button>
- <p>
- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
- mollit anim id est laborum.
- </p>
+ <h2 set:html={t(tPage, { key: 'news' })} />
+ {mostRecentNewsItem && <NewsPreviewLink newsItem={mostRecentNewsItem} />}
+ <div class="align-end margin-block-start-md">
+ <a href={`/${locale}/news`} class="btn">
+ {t(tPage, { key: 'aw-news' })} ▷
+ </a>
+ </div>
</section>
+
+ <section>
+ <h2 set:html={t(tPage, { key: 'furthsettins' })} />
+ <p set:html={t(tPage, { key: 'furthsettins-para' })} />
+ <div class="align-end">
+ <a href={`/${locale}/furthsettins`} class="btn">
+ {t(tPage, { key: 'aw-furthsettins' })} ▷
+ </a>
+ </div>
+ </section>
+
<section>
- <h2>Seicont-level heidin</h2>
- <h3>Third-level heidin</h3>
- <h4>Fowert-level heidin</h4>
- <p>
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
- labore et dolore magna aliqua.
- </p>
- <a class="link" href="#">Lairn mair!</a>
- <p>
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
- commodo consequat.
- </p>
- <button class="btn">Dae somethin excitin...</button>
- <p>
- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
- mollit anim id est laborum.
- </p>
+ <h2 set:html={t(tPage, { key: 'jyne' })} />
+
+ <h3 set:html={t(tPage, { key: 'why-jyne' })} />
+ <p set:html={t(tPage, { key: 'why-jyne-para-1' })} />
+ <p set:html={t(tPage, { key: 'why-jyne-para-2' })} />
+ <p set:html={t(tPage, { key: 'why-jyne-para-3' })} />
+
+ <h3 set:html={t(tPage, { key: 'hou-jyne' })} />
+ <p set:html={t(tPage, { key: 'hou-jyne-para-1' })} />
+ <p
+ set:html={t(tPage, {
+ key: 'hou-jyne-para-2',
+ membershipEmail: contactDetails.membershipSecretary.emailAddress,
+ })}
+ />
+ </section>
+
+ <section id="contact">
+ <h2 set:html={t(tPage, { key: 'contact' })} />
+ <a class="link" href={`${locale}/mailto:${contactDetails.generalEnquiries.emailAddress}`}>
+ {contactDetails.generalEnquiries.emailAddress}
+ </a>
+ <address>
+ Scots Language Society<br />
+ c/o 61 Cliffburn Road<br />
+ Arbroath<br />
+ Angus<br />
+ DD11 5BA<br />
+ United Kingdom<br />
+ </address>
</section>
</Page>
diff --git a/src/pages/[locale]/news/index.astro b/src/pages/[locale]/news/index.astro
index 0c81fd9..c64fbdb 100644
--- a/src/pages/[locale]/news/index.astro
+++ b/src/pages/[locale]/news/index.astro
@@ -6,18 +6,13 @@ import getLocaleFromPath from '$lib/getLocaleFromPath';
import localeStaticPaths from '$lib/localeStaticPaths';
import { getCollection } from 'astro:content';
import NewsPreviewLink from '$components/NewsPreviewLink.astro';
+import { isNewsItemInLocale } from '$lib/newsUtils';
const allNews = await getCollection('news');
const locale = getLocaleFromPath(Astro.url.pathname);
-const allNewsInLocale = allNews.filter(isInLocale);
+const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale));
const t = translate(locale);
-function isInLocale(newsItem: (typeof allNews)[number]) {
- const srcPath = newsItem.id;
- const newsItemLocale = srcPath.slice(0, srcPath.indexOf('/'));
- return newsItemLocale === locale;
-}
-
export async function getStaticPaths() {
return localeStaticPaths;
}