From 5613bf767a61f93b748ef9a84e3048f51ff73994 Mon Sep 17 00:00:00 2001 From: Zonily Jame Date: Fri, 20 Nov 2026 23:52:34 +0800 Subject: [PATCH 1/3] Improve search discovery for Flutter Philippines --- e2e/legacy-redirects.spec.ts | 1 + e2e/search-discovery.spec.ts | 62 +++++++++++++++++++++++++++ src/app/layout.tsx | 25 ----------- src/app/page.tsx | 70 +++++++++++++++++++++++++++++++ src/app/robots.ts | 11 +++++ src/app/sitemap.ts | 8 ++++ src/components/home/Hero.tsx | 4 +- src/components/home/JoinPanel.tsx | 7 ++-- src/components/home/Steps.tsx | 8 ++-- 9 files changed, 162 insertions(+), 34 deletions(-) create mode 100644 e2e/search-discovery.spec.ts create mode 100644 src/app/robots.ts create mode 100644 src/app/sitemap.ts diff --git a/e2e/legacy-redirects.spec.ts b/e2e/legacy-redirects.spec.ts index 688147a..eb9e417 100644 --- a/e2e/legacy-redirects.spec.ts +++ b/e2e/legacy-redirects.spec.ts @@ -18,6 +18,7 @@ test.describe("legacy flutter.ph URLs keep working", () => { expect(html).toContain(`content="0; url=${target.to}"`); expect(html).toContain(`href="${target.to}"`); expect(html).toContain('name="robots" content="noindex'); + expect(html).not.toContain('rel="canonical"'); }); } } diff --git a/e2e/search-discovery.spec.ts b/e2e/search-discovery.spec.ts new file mode 100644 index 0000000..3e0bc6f --- /dev/null +++ b/e2e/search-discovery.spec.ts @@ -0,0 +1,62 @@ +import { expect, test } from "@playwright/test"; +import { site, social } from "../src/lib/site"; + +const home = new URL("/", site.url).href; + +test.use({ javaScriptEnabled: false }); +test.beforeEach(({}, testInfo) => { + test.skip(testInfo.project.name !== "desktop-1280", "Static output is viewport-independent."); +}); + +test("robots and sitemap expose only the canonical homepage", async ({ request }) => { + const robots = await request.get("/robots.txt"); + expect(robots.ok()).toBe(true); + const rules = await robots.text(); + expect(rules).toMatch(/^User-agent:\s*\*\s*$/im); + expect(rules).toMatch(/^Allow:\s*\/\s*$/im); + expect(rules.split(/\r?\n/)).toContain(`Sitemap: ${home}sitemap.xml`); + + const sitemap = await request.get("/sitemap.xml"); + expect(sitemap.ok()).toBe(true); + const xml = await sitemap.text(); + expect(Array.from(xml.matchAll(/(.*?)<\/loc>/g), ([, url]) => url)).toEqual([home]); +}); + +test("homepage metadata, linked entities and answers are available without JavaScript", async ({ + page, +}) => { + await page.goto("/"); + const canonical = page.locator('link[rel="canonical"]'); + await expect(canonical).toHaveCount(1); + expect(new URL((await canonical.getAttribute("href"))!).href).toBe(home); + expect(await page.locator('meta[name="robots"][content*="noindex" i]').count()).toBe(0); + const title = await page.title(); + expect(title).toContain(site.name); + expect(title).not.toBe(site.name); + + const description = await page.locator('meta[name="description"]').getAttribute("content"); + expect(description).toBeTruthy(); + for (const tag of ['meta[property="og:description"]', 'meta[name="twitter:description"]']) { + await expect(page.locator(tag)).toHaveAttribute("content", description!); + } + const ogUrl = await page.locator('meta[property="og:url"]').getAttribute("content"); + expect(new URL(ogUrl!).href).toBe(home); + + const graphs = await page.locator('script[type="application/ld+json"]').allTextContents(); + const nodes = graphs.flatMap((text) => JSON.parse(text)["@graph"] ?? []); + const organization = nodes.find((node) => node["@type"] === "Organization"); + const website = nodes.find((node) => node["@type"] === "WebSite"); + expect(organization).toMatchObject({ name: site.name }); + expect(organization["@id"]).toBeTruthy(); + expect(organization.sameAs).toEqual(expect.arrayContaining([social.github.href])); + expect(website).toMatchObject({ publisher: { "@id": organization["@id"] } }); + + await expect(page.locator("#get-involved h2")).toHaveText(/\?/); + await expect(page.locator("#get-involved")).toContainText(/Metro Manila/); + await expect(page.locator("#learn h2")).toHaveText(/\?/); + await expect(page.locator("#learn")).toContainText(/codelab/i); + const join = page.locator("#join-community"); + await expect(join.locator("h2")).toHaveText(/join Flutter Philippines/i); + await expect(join.getByRole("link", { name: /Facebook/i })).toHaveAttribute("href", site.joinUrl); + await expect(join.getByRole("link", { name: /Luma/i })).toHaveAttribute("href", social.luma.href); +}); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 70256a1..aea1b5e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -10,35 +10,10 @@ import { themeScript } from "./theme-script"; import { site } from "@/lib/site"; import "./globals.css"; -/** Share card, generated by `pnpm og` into public/og.jpg. */ -const ogAlt = - "Flutter Philippines: join thousands of developers, designers and founders building apps with Flutter, Dart and AI."; - export const metadata: Metadata = { metadataBase: new URL(site.url), title: { default: site.name, template: `%s | ${site.name}` }, - description: - "A community of designers, developers and founders in the Philippines building apps with Flutter, Dart and AI. Events, learning resources and ways to join.", applicationName: site.name, - alternates: { canonical: "/" }, - openGraph: { - siteName: site.name, - title: site.name, - description: - "Join thousands of developers, designers and founders building apps with Flutter, Dart and AI.", - url: "/", - locale: site.locale, - type: "website", - images: [{ url: "/og.jpg", width: 1200, height: 630, alt: ogAlt }], - }, - twitter: { - card: "summary_large_image", - site: "@flutter_ph", - title: site.name, - description: - "Join thousands of developers, designers and founders building apps with Flutter, Dart and AI.", - images: [{ url: "/og.jpg", alt: ogAlt }], - }, }; export const viewport: Viewport = { diff --git a/src/app/page.tsx b/src/app/page.tsx index 9bce299..5dba9ca 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,3 +1,4 @@ +import type { Metadata } from "next"; import { AiSection } from "@/components/home/AiSection"; import { Hero } from "@/components/home/Hero"; import { JoinPanel } from "@/components/home/JoinPanel"; @@ -11,6 +12,71 @@ import { getHighlightEvent, getUpcomingEvents, } from "@/lib/content"; +import { site, social } from "@/lib/site"; + +const title = `${site.name} | Flutter and Dart Meetups`; +const description = + "Find Flutter and Dart meetups in Metro Manila and online, explore beginner resources, and join the Flutter Philippines community on Facebook."; +const homeUrl = new URL("/", site.url).href; +const organizationId = new URL("#organization", homeUrl).href; +const image = { + url: "/og.jpg", + alt: "Flutter Philippines: join thousands of developers, designers and founders building apps with Flutter, Dart and AI.", +}; + +export const metadata: Metadata = { + title: { absolute: title }, + description, + alternates: { canonical: homeUrl }, + openGraph: { + type: "website", + title, + description, + url: homeUrl, + siteName: site.name, + locale: site.locale, + images: [{ ...image, width: 1200, height: 630 }], + }, + twitter: { + card: "summary_large_image", + site: "@flutter_ph", + title, + description, + images: [image], + }, +}; + +const graph = { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Organization", + "@id": organizationId, + name: site.name, + alternateName: site.shortName, + description: site.tagline, + url: homeUrl, + logo: new URL("/flutter-ph-logo.svg", homeUrl).href, + sameAs: [ + social.facebook.href, + social.luma.href, + social.instagram.href, + social.x.href, + social.linkedin.href, + social.github.href, + ], + }, + { + "@type": "WebSite", + "@id": new URL("#website", homeUrl).href, + url: homeUrl, + name: site.name, + alternateName: site.shortName, + inLanguage: "en-PH", + publisher: { "@id": organizationId }, + }, + ], +}; export default function HomePage() { const now = new Date(); @@ -22,6 +88,10 @@ export default function HomePage() { id="main" className="grid gap-[var(--sheet-gap)] px-[max(12px,env(safe-area-inset-left))] pb-[var(--sheet-gap)]" > +