Skip to content

Commit 0124181

Browse files
committed
refine locale metadata and newsletter links
1 parent 1a73b2a commit 0124181

11 files changed

Lines changed: 54 additions & 12 deletions

File tree

messages/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
"Index": {
118118
"title": "Finde ein Zuhause für deine Küchenabfälle, wo auch immer du bist",
119119
"subtitle": "Peels verbindet die Menschen mit Lebensmittelkratzern mit denen, die komponieren. Es ist ein kostenloses und nicht-kommerzielles Gemeinschaftsprojekt.",
120+
"metaDescription": "Peels verbindet Menschen mit Lebensmittelresten mit denjenigen, die kompostieren. Es ist ein kostenloses, nicht-kommerzielles Gemeinschaftsprojekt.",
121+
"metaKeywords": "Lebensmittelabfall, Essensreste, Kompost, Kompost in meiner Nähe, Kompost-Abgabestelle, Abgabe von Lebensmittelresten",
120122
"hostAvatarAlt": "Der Avatar eines Peels-Gastgebers",
121123
"buttons": {
122124
"browseMap": "Karte durchsuchen",

messages/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
"Index": {
118118
"title": "Find a home for your food scraps, wherever you are",
119119
"subtitle": "Peels connects folks with food scraps to those who compost. It’s a free, non-commercial, community project.",
120+
"metaDescription": "Peels connects folks with food scraps to those who compost. It’s a free, non-commercial, community project.",
121+
"metaKeywords": "food waste, food scraps, share waste, sharewaste, makesoil, compost near me, compost drop-off, food scrap drop-off",
120122
"hostAvatarAlt": "The avatar for a Peels host",
121123
"buttons": {
122124
"browseMap": "Browse the map",

messages/es.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
"Index": {
118118
"title": "Encuentra un hogar para tus restos de comida, estés donde estés",
119119
"subtitle": "Peels conecta a personas con restos de comida con quienes hacen compost. Es un proyecto comunitario, gratuito y sin fines de lucro.",
120+
"metaDescription": "Peels conecta a personas con restos de comida con quienes hacen compost. Es un proyecto comunitario, gratuito y sin fines de lucro.",
121+
"metaKeywords": "desperdicio alimentario, restos de comida, compost, compost cerca de mí, punto de compostaje, entrega de restos de comida",
120122
"hostAvatarAlt": "El avatar de un anfitrión de Peels",
121123
"buttons": {
122124
"browseMap": "Explorar el mapa",

messages/fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
"Index": {
118118
"title": "Trouvez une destination pour vos restes alimentaires, où que vous soyez",
119119
"subtitle": "Peels met en relation des personnes qui ont des restes alimentaires avec celles qui compostent. C’est un projet communautaire gratuit et non commercial.",
120+
"metaDescription": "Peels met en relation des personnes qui ont des restes alimentaires avec celles qui compostent. C’est un projet communautaire gratuit et non commercial.",
121+
"metaKeywords": "gaspillage alimentaire, restes alimentaires, compost, compost près de chez moi, point de dépôt compost, dépôt de restes alimentaires",
120122
"hostAvatarAlt": "L’avatar d’une personne hôte sur Peels",
121123
"buttons": {
122124
"browseMap": "Parcourir la carte",

messages/pt-BR.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
"Index": {
118118
"title": "Encontre um destino para os seus restos de comida, esteja onde estiver",
119119
"subtitle": "O Peels liga pessoas com restos de comida a quem faz compostagem. É um projeto comunitário, gratuito e sem fins comerciais.",
120+
"metaDescription": "O Peels liga pessoas com restos de comida a quem faz compostagem. É um projeto comunitário, gratuito e sem fins comerciais.",
121+
"metaKeywords": "desperdício de alimentos, restos de comida, compostagem, compostagem perto de mim, ponto de entrega para compostagem, entrega de restos de comida",
120122
"hostAvatarAlt": "O avatar de uma pessoa anfitriã do Peels",
121123
"buttons": {
122124
"browseMap": "Explorar o mapa",

src/app/(core)/(interact)/(centered)/profile/page.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ export default async function ProfilePage() {
4242
supabase.from("profiles").select().eq("id", user.id).single(),
4343
]);
4444

45+
const userMetadataPreferredLocale = user?.user_metadata?.preferred_locale;
4546
const preferredLocale =
4647
normaliseLocale(profile?.preferred_locale) ??
47-
normaliseLocale(user?.user_metadata?.preferred_locale) ??
48+
(typeof userMetadataPreferredLocale === "string"
49+
? normaliseLocale(userMetadataPreferredLocale)
50+
: undefined) ??
4851
"en";
4952

5053
return (

src/app/(core)/(static)/(index)/page.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Suspense } from "react";
22
import { useTranslations } from "next-intl";
3+
import { getTranslations } from "next-intl/server";
34
import Link from "next/link";
45
import { siteConfig } from "@/config/site";
56
import IntroHeader from "@/components/IntroHeader";
@@ -13,11 +14,30 @@ import HeaderBlock from "@/components/HeaderBlock";
1314
import FooterBlock from "@/components/FooterBlock";
1415
import { styled } from "@pigment-css/react";
1516

16-
export const metadata = {
17-
title: {
18-
absolute: `${siteConfig.name}: ${siteConfig.description}`,
19-
},
20-
};
17+
export async function generateMetadata() {
18+
const t = await getTranslations("Index");
19+
const description = t("metaDescription");
20+
const keywords = t("metaKeywords")
21+
.split(",")
22+
.map((keyword) => keyword.trim())
23+
.filter(Boolean);
24+
25+
return {
26+
title: {
27+
absolute: `${siteConfig.name}: ${t("title")}`,
28+
},
29+
description,
30+
keywords,
31+
openGraph: {
32+
title: `${siteConfig.name}: ${t("title")}`,
33+
description,
34+
},
35+
twitter: {
36+
title: `${siteConfig.name}: ${t("title")}`,
37+
description,
38+
},
39+
};
40+
}
2141

2242
export default function Index() {
2343
const t = useTranslations("Index");

src/app/(core)/(static)/newsletter/feed.xml/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function GET(request: Request) {
2525
});
2626

2727
newsletterIssues.forEach((issue) => {
28-
const issueLink = `${siteConfig.url}/newsletter/${issue.slug}`;
28+
const issueLink = `${siteConfig.url}/newsletter/${issue.slug}?locale=${locale}`;
2929
const issueImage = new URL(
3030
getNewsletterIssueImageUrl(
3131
issue.customMetadata.issueNumber,
@@ -35,7 +35,7 @@ export async function GET(request: Request) {
3535
).toString();
3636
feed.addItem({
3737
title: issue.metadata.title,
38-
link: `${siteConfig.url}/newsletter/${issue.slug}`,
38+
link: issueLink,
3939
description: issue.metadata.description,
4040
author: issue.metadata.authors.map((author) => ({
4141
name: author,

src/utils/postgrest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function isMissingPostgrestColumn(
99
) {
1010
return (
1111
error.code === "PGRST204" &&
12-
new RegExp(columnName, "i").test(error.message ?? "")
12+
(error.message ?? "").toLowerCase().includes(columnName.toLowerCase())
1313
);
1414
}
1515

supabase/functions/_shared/newsletter.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,17 @@ export const getNewsletterEmailSubject = (locale: SupportedLocale) => {
211211
return `${copy.subjectPrefix}: ${issue.title}`;
212212
};
213213

214-
export const getNewsletterIssueUrl = () =>
215-
`https://www.peels.app/newsletter/${currentIssue.slug}`;
214+
export const getNewsletterIssueUrl = (locale?: SupportedLocale) => {
215+
const issueUrl = new URL(
216+
`https://www.peels.app/newsletter/${currentIssue.slug}`
217+
);
218+
219+
if (locale && locale !== defaultEmailLocale) {
220+
issueUrl.searchParams.set("locale", locale);
221+
}
222+
223+
return issueUrl.toString();
224+
};
216225

217226
export const getNewsletterAudienceConfigs = (): Array<{
218227
locale: SupportedLocale;

0 commit comments

Comments
 (0)