SPB Git

Repository Public

page.tsx 6.2 KB 171 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/page.tsx9 * Module           : app10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-0812 * Last Modified    : 2026-08-2513 *14 * Author           : Simon-Pierre Boucher15 * Position         : Professor of Finance16 * Institution      : Université du Québec en Outaouais (UQO)17 * Organization     : SP Boucher18 * Website          : https://spboucher.ai19 * Git              : https://git.spboucher.ai20 *21 * Preferred Contact: contact@spboucher.ai22 * Development      : dev@spboucher.ai23 * Support          : support@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142import type { Metadata } from "next";43import Link from "next/link";44import HomeClient, { type PulseItem, type RecentSaleItem } from "./HomeClient";45import stats from "@/data/stats.json";46import { getMarketIndex, recentSales, salesCountSince } from "@/lib/db";47import { moneyFr, slugify } from "@/lib/seo";4849// Le pouls du marché et les dernières ventes bougent au rythme du connecteur50// (quotidien) — régénération ISR horaire, le reste de la page est stable.51export const revalidate = 3600;5253export const metadata: Metadata = {54  title: {55    absolute: "Vrai-Prix — estimation immobilière gratuite au Québec",56  },57  description:58    "Estimez gratuitement la valeur de n'importe quelle propriété du Québec : 3,7 millions d'unités d'évaluation, 745 119 ventes réelles, fourchette honnête P10-P90 et calcul montré en entier.",59  alternates: { canonical: "/" },60  openGraph: {61    type: "website",62    siteName: "Vrai-Prix",63    locale: "fr_CA",64    url: "/",65    title:66      "Vrai-Prix — estimation immobilière gratuite au Québec",67    description:68      "Estimez gratuitement la valeur de n'importe quelle propriété du Québec : 3,7 millions d'unités d'évaluation, 745 119 ventes réelles, fourchette honnête P10-P90 et calcul montré en entier.",69    images: [70      { url: "/og.png", width: 1200, height: 630 },71    ],72  },73};7475const TOP_VILLES = (76  stats as { par_ville: { ville: string; n: number; mediane: number | null }[] }77).par_ville.slice(0, 24);7879/** Séries d'indice par grand type — historique complet (le client fenêtre 12/24/tout). */80function buildPulse(): PulseItem[] {81  return (["unifamilial", "condo", "plex"] as const).map((type) => {82    const full = getMarketIndex(type);83    const series = full;84    const last = full.length ? full[full.length - 1].idx : null;85    const yearAgo = full.length >= 13 ? full[full.length - 13].idx : null;86    const first = full.length >= 2 ? full[0].idx : null;87    return {88      type,89      series,90      pct12m:91        last != null && yearAgo != null && yearAgo > 092          ? (last / yearAgo - 1) * 10093          : null,94      since2021:95        last != null && first != null && first > 0 ? (last / first - 1) * 100 : null,96    };97  });98}99100function buildRecent(): RecentSaleItem[] {101  return recentSales(6).map((s) => ({102    id: s.id,103    date: s.date,104    amount: s.amount,105    street: s.street,106    city: s.city,107    propertyType: s.property_type,108    idProvinc: s.id_provinc,109    vsRolePct:110      s.valeur_role != null && s.valeur_role > 0111        ? (s.amount / s.valeur_role - 1) * 100112        : null,113  }));114}115116function iso(d: Date): string {117  return d.toISOString().slice(0, 10);118}119120export default function Home() {121  const monthAgo = new Date();122  monthAgo.setDate(monthAgo.getDate() - 30);123  return (124    <>125      <HomeClient126        pulse={buildPulse()}127        recent={buildRecent()}128        salesLast30d={salesCountSince(iso(monthAgo))}129      />130      {/* ---- Explorer par municipalité (maillage interne indexable) ---- */}131      <section className="mt-14">132        <header className="sec">133          <span className="sec-num">05 — Explorer par municipalité</span>134          <h2 className="vp-display mt-2 max-w-3xl text-[clamp(24px,3.6vw,36px)] font-bold uppercase leading-[1.02] tracking-[-0.03em]">135            La valeur des propriétés, ville par ville136          </h2>137          <p className="mt-3 max-w-2xl text-[14.5px] leading-relaxed text-ink-2">138            Statistiques d&apos;évaluation, valeur médiane et propriétés estimées139            pour chacune des 1 097 municipalités du Québec.140          </p>141        </header>142        <ul className="mt-6 grid grid-cols-2 gap-x-8 sm:grid-cols-3 lg:grid-cols-4">143          {TOP_VILLES.map((v) => (144            <li key={v.ville}>145              <Link146                href={`/municipalite/${slugify(v.ville)}`}147                className="group flex items-baseline justify-between gap-2 border-b border-[rgba(20,24,20,0.1)] py-2 text-[13.5px]"148              >149                <span className="font-medium group-hover:text-accent-deep">150                  {v.ville}151                </span>152                <span className="vp-mono text-[10.5px] text-ink-3">153                  {v.mediane != null ? moneyFr(v.mediane) : ""}154                </span>155              </Link>156            </li>157          ))}158        </ul>159        <p className="mt-6">160          <Link161            href="/municipalites"162            className="vp-mono border-b border-accent pb-px text-[11px] uppercase tracking-[0.08em] text-accent-deep hover:text-accent"163          >164            Toutes les municipalités →165          </Link>166        </p>167      </section>168    </>169  );170}171
Files main
Menu

Theme