diff --git a/app/[[...mdxPath]]/page.jsx b/app/[[...mdxPath]]/page.jsx index 3affba8..e0b234e 100644 --- a/app/[[...mdxPath]]/page.jsx +++ b/app/[[...mdxPath]]/page.jsx @@ -1,12 +1,17 @@ import { generateStaticParamsFor, importPage } from 'nextra/pages' import { useMDXComponents as getMDXComponents } from '../../mdx-components' +import { pageMetadata } from '@/lib/seo' export const generateStaticParams = generateStaticParamsFor('mdxPath') export async function generateMetadata(props) { const params = await props.params const { metadata } = await importPage(params.mdxPath) - return metadata + const route = params.mdxPath?.length ? `/${params.mdxPath.join('/')}` : '/' + return { + ...metadata, + ...pageMetadata({ route, title: metadata.title, description: metadata.description }) + } } const Wrapper = getMDXComponents().wrapper diff --git a/app/layout.jsx b/app/layout.jsx index b90451a..edef5b7 100644 --- a/app/layout.jsx +++ b/app/layout.jsx @@ -6,6 +6,7 @@ import 'nextra-theme-docs/style.css' import './globals.css' import { SiteLogo } from '@/components/brand/seal' import { SiteFooter } from '@/components/site/site-footer' +import { OG_IMAGE, SITE_DESCRIPTION, SITE_NAME, SITE_URL } from '@/lib/seo' // Atkinson Hyperlegible Next and Mono: designed so that 0/O and 1/l/I never // look alike, which matters on a site full of keys, digests and IDs. @@ -40,12 +41,18 @@ const codeFont = localFont({ }) export const metadata = { + metadataBase: new URL(SITE_URL), title: { - default: 'Selcom Developers', - template: '%s | Selcom Developers' + default: SITE_NAME, + template: `%s | ${SITE_NAME}` }, - description: - 'Open-source community clients for the Selcom payment API in Java, Node.js, Python, PHP and Laravel. Not affiliated with Selcom Paytech Ltd.' + description: SITE_DESCRIPTION, + // Pages set their own openGraph (see app/[[...mdxPath]]/page.jsx). The card + // has no title or description here, so X falls back to each page's og: tags. + twitter: { + card: 'summary_large_image', + images: [OG_IMAGE.url] + } } const navbar = ( diff --git a/app/robots.js b/app/robots.js new file mode 100644 index 0000000..0c2118e --- /dev/null +++ b/app/robots.js @@ -0,0 +1,8 @@ +export const dynamic = 'force-static' + +export default function robots() { + return { + rules: { userAgent: '*', allow: '/' }, + sitemap: 'https://selcom-developers.github.io/sitemap.xml' + } +} diff --git a/app/sitemap.js b/app/sitemap.js new file mode 100644 index 0000000..d571717 --- /dev/null +++ b/app/sitemap.js @@ -0,0 +1,27 @@ +import fs from 'node:fs' +import path from 'node:path' + +export const dynamic = 'force-static' + +const SITE = 'https://selcom-developers.github.io' +const CONTENT = path.join(process.cwd(), 'content') + +// One entry per page under content/: "index.mdx" maps to its folder's path. +function pages(dir, prefix = '') { + return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + if (entry.isDirectory()) return pages(path.join(dir, entry.name), `${prefix}/${entry.name}`) + if (!/\.mdx?$/.test(entry.name)) return [] + const name = entry.name.replace(/\.mdx?$/, '') + return [name === 'index' ? prefix || '/' : `${prefix}/${name}`] + }) +} + +export default function sitemap() { + return pages(CONTENT) + .sort() + .map((route) => ({ + url: route === '/' ? `${SITE}/` : `${SITE}${route}`, + changeFrequency: 'monthly', + priority: route === '/' ? 1 : route.split('/').length === 2 ? 0.8 : 0.6 + })) +} diff --git a/content/community/links.mdx b/content/community/links.mdx index 06efc2a..fd14c76 100644 --- a/content/community/links.mdx +++ b/content/community/links.mdx @@ -23,3 +23,7 @@ Our community clients are separate. They are written from scratch and do not cop - [selcom-spec](https://github.com/selcom-developers/selcom-spec) - [Contributing](/community/contributing) - [Security reporting](/community/security) + +## Other African payment APIs + +- [Malipo](https://alphaolomi.github.io/awesome-payment-integrations/): a curated directory of African payment providers with usable APIs, and the SDKs for them. diff --git a/lib/seo.js b/lib/seo.js new file mode 100644 index 0000000..ebe291e --- /dev/null +++ b/lib/seo.js @@ -0,0 +1,30 @@ +// Shared metadata for link previews and search engines. +export const SITE_URL = 'https://selcom-developers.github.io' +export const SITE_NAME = 'Selcom Developers' +export const SITE_DESCRIPTION = + 'Open-source community clients for the Selcom payment API in Java, Node.js, Python, PHP and Laravel. Not affiliated with Selcom Paytech Ltd.' + +export const OG_IMAGE = { + url: '/og.png', + width: 1200, + height: 630, + alt: 'Selcom Developers: community clients for the Selcom payment API' +} + +// Open Graph and canonical metadata for one page. Next.js replaces a parent's +// openGraph object rather than merging it, so every page sets the full object. +export function pageMetadata({ route, title, description }) { + const isHome = route === '/' + return { + alternates: { canonical: route }, + openGraph: { + type: 'website', + siteName: SITE_NAME, + locale: 'en', + url: route, + title: isHome || !title ? SITE_NAME : `${title} | ${SITE_NAME}`, + description: description || SITE_DESCRIPTION, + images: [OG_IMAGE] + } + } +} diff --git a/public/og.png b/public/og.png new file mode 100644 index 0000000..9c980b0 Binary files /dev/null and b/public/og.png differ