SPB Git

Repository Public

seo.ts 4.5 KB 86 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : ORIX App Universe8 * File             : src/lib/seo.ts9 * Module           : lib10 * Repository       : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website  : https://www.orixlab.dev12 * Created          : 2026-11-2113 * Last Modified    : 2026-11-2114 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import type { Metadata } from "next";44import type { AppDoc } from "@/models/app";45import { env } from "./env";46import { dict, href, tr, type Locale } from "./i18n";47import type { Release } from "./releases/store";48import { betaAccess } from "./testflight";49import { downloadUrl, iconUrl } from "./view";5051export const abs = (path: string) => env.publicUrl + path;5253/** Canonical URL of the page plus its hreflang twins. */54export function alternates(path: string, locale: Locale): NonNullable<Metadata["alternates"]> {55  return { canonical: abs(href(locale, path)), languages: { en: abs(href("en", path)), "fr-CA": abs(href("fr", path)), "x-default": abs(href("en", path)) } };56}5758export const organizationLd = (locale: Locale) => ({59  "@context": "https://schema.org", "@type": "WebSite", name: "ORIX", url: abs(href(locale, "/")), inLanguage: locale === "fr" ? "fr-CA" : "en",60  description: dict(locale).hero.body, publisher: { "@type": "Person", name: "Simon-Pierre Boucher", url: "https://www.spboucher.ai" },61});6263const OS: Record<string, string> = { ios: "iOS", ipados: "iPadOS", macos: "macOS" };64const CATEGORY: Record<string, string> = { productivity: "ProductivityApplication", utilities: "UtilitiesApplication", "photo-video": "MultimediaApplication", audio: "MultimediaApplication", security: "SecurityApplication", system: "UtilitiesApplication",65  music: "MultimediaApplication", ai: "UtilitiesApplication", developer: "DeveloperApplication", browser: "BrowserApplication", navigation: "TravelApplication", games: "GameApplication" };6667/**68 * schema.org SoftwareApplication with verified facts only: no rating, no review, no price while none is set.69 * `softwareVersion` and `downloadUrl` appear only for something a visitor can actually obtain.70 */71export function softwareLd(app: AppDoc, locale: Locale, artifact: Release | null) {72  const beta = betaAccess(app);73  const obtainable = !!artifact || beta.kind === "join";74  const icon = iconUrl(app);75  return {76    "@context": "https://schema.org", "@type": "SoftwareApplication", name: app.name, url: abs(href(locale, `/apps/${app.slug}`)), inLanguage: locale === "fr" ? "fr-CA" : "en",77    description: tr(app.summary, locale), applicationCategory: CATEGORY[app.category],78    operatingSystem: app.platforms.map((p) => `${OS[p]}${app.minOS[p] ? ` ${app.minOS[p]}+` : ""}`).join(", "),79    ...(icon ? { image: abs(icon) } : {}),80    ...(obtainable && (artifact?.version ?? app.version) ? { softwareVersion: artifact?.version ?? app.version } : {}),81    ...(artifact ? { downloadUrl: abs(downloadUrl(artifact)), fileSize: artifact.asset_size ? `${Math.round(artifact.asset_size / 1_000_000)}MB` : undefined, datePublished: artifact.published_at?.slice(0, 10) } : {}),82    ...(beta.kind === "join" ? { installUrl: beta.url, releaseNotes: abs(href(locale, `/apps/${app.slug}#changelog`)) } : {}),83    author: { "@type": "Person", name: "Simon-Pierre Boucher", url: "https://www.spboucher.ai" },84  };85}86
Files main
Menu

Theme