Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ Run `pnpm build` (or `pnpm build:preview`) before `pnpm test:e2e` and `pnpm test
- Motion is CSS scroll-driven animation, transform-only, and switches off with reduced motion
- About 3 KB of our own JavaScript on top of the framework

## Share card

Links to flutter.ph show this preview on Facebook, X, LinkedIn and chat apps. It is rendered in Chromium with the site's own fonts by `pnpm og` into `public/og.jpg` (1200 x 630). Re-run it after changing the name, tagline or logo.

![Share card](public/og.jpg)

## Deploy

Pushes to `main` build and publish to GitHub Pages through `.github/workflows/deploy.yml`, which also runs daily at midnight Manila time. One-time setup by a maintainer: **Settings > Pages > Source = GitHub Actions**, and the custom domain `flutter.ph`.
Expand Down
Binary file modified docs/screenshots/desktop-about.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/desktop-events.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"lighthouse": "lhci autorun",
"analyze": "ANALYZE=true next build --webpack",
"check": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test && pnpm build:preview && pnpm test:e2e && pnpm test:perf",
"test:perf": "playwright test --config playwright.perf.config.ts"
"test:perf": "playwright test --config playwright.perf.config.ts",
"og": "node scripts/build-og.mjs"
},
"dependencies": {
"@fontsource-variable/google-sans": "^5.3.2",
Expand Down
Binary file added public/og.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions scripts/build-og.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env node
// Renders the share card (Open Graph and X/Twitter) to public/og.jpg, 1200x630.
// Uses real Chromium so the card is set in the site's own Google Sans.
// Usage: pnpm og (re-run after changing the name, tagline or logo)
import { chromium } from "@playwright/test";
import { readFile, writeFile } from "node:fs/promises";
import sharp from "sharp";

const root = new URL("../", import.meta.url);
const font = (w) =>

Check warning on line 10 in scripts/build-og.mjs

View workflow job for this annotation

GitHub Actions / check

'w' is defined but never used
readFile(
new URL(
"node_modules/@fontsource-variable/google-sans/files/google-sans-latin-wght-normal.woff2",
root,
),
).then((b) => `data:font/woff2;base64,${b.toString("base64")}`);
const logo = await readFile(new URL("public/flutter-ph-logo.svg", root), "utf8");
const fontUrl = await font();

const html = `<!doctype html><html><head><style>
@font-face { font-family: "Google Sans"; src: url(${fontUrl}) format("woff2"); font-weight: 400 700; }
* { box-sizing: border-box; margin: 0; }
html, body { width: 1200px; height: 630px; }
body { background: #e8ebf0; padding: 36px; font-family: "Google Sans", sans-serif; display: flex; }
.sheet { flex: 1; background: #fff; border-radius: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 76px; overflow: hidden; position: relative; }
.copy { width: 660px; }
h1 { font-size: 84px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; color: #0b0d12; }
p { text-wrap: balance; margin-top: 26px; font-size: 33px; line-height: 1.3; letter-spacing: -0.015em; color: #4f5764; font-weight: 500; }
.pill { display: inline-flex; margin-top: 42px; background: #0b0d12; color: #fff; border-radius: 999px; padding: 14px 30px; font-size: 27px; font-weight: 600; }
.logo svg { width: 300px; height: auto; display: block; }
</style></head><body><div class="sheet"><div class="copy">
<h1>Flutter Philippines</h1>
<p>Join thousands of developers, designers and founders building apps with Flutter, Dart and AI.</p>
<div class="pill">flutter.ph</div></div>
<div class="logo">${logo}</div></div></body></html>`;

const browser = await chromium.launch();
const page = await browser.newPage({
viewport: { width: 1200, height: 630 },
deviceScaleFactor: 1,
});
await page.setContent(html, { waitUntil: "load" });
await page.evaluate(() => document.fonts.ready);
const png = await page.screenshot({ type: "png" });
await browser.close();

const jpg = await sharp(png)
.jpeg({ quality: 88, mozjpeg: true, chromaSubsampling: "4:4:4" })
.toBuffer();
await writeFile(new URL("public/og.jpg", root), jpg);
console.log(`public/og.jpg written (${Math.round(jpg.length / 1024)} KB, 1200x630)`);
27 changes: 25 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,35 @@ 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: site.tagline,
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,
openGraph: { siteName: site.name, locale: site.locale, type: "website" },
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 = {
Expand Down
Loading