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
3 changes: 3 additions & 0 deletions .github/workflows/sync-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
# otherwise Vercel skips the deployment.
git config user.name "m-junaidd"
git config user.email "176620033+m-junaidd@users.noreply.github.com"
# Refresh the sitemap's page dates from the full history. Never
# allowed to stop a deploy: on any failure the committed file is used.
node scripts/page-dates.mjs && git add lib/page-dates.json || echo "Page dates not refreshed"
git commit --amend --no-edit --reset-author
git remote add fork https://x-access-token:${{ secrets.FORK_SYNC_TOKEN }}@github.com/m-junaidd/web-platform.git
git push fork HEAD:main --force
23 changes: 23 additions & 0 deletions app/.well-known/security.txt/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SITE_URL } from '@/lib/seo'

// Built with the site, so the expiry date moves forward with every deploy
export const dynamic = 'force-static'

/**
* Where to report a security problem (RFC 9116). The address is the one
* SECURITY.md in the repository already gives. The file must carry an expiry
* date less than a year away.
*/
export function GET() {
const expires = new Date(Date.now() + 364 * 24 * 60 * 60 * 1000)
expires.setUTCHours(0, 0, 0, 0)

const body = `Contact: mailto:info@devweekends.com
Expires: ${expires.toISOString()}
Preferred-Languages: en
Canonical: ${SITE_URL}/.well-known/security.txt
Policy: https://github.com/devweekends/web-platform/blob/main/SECURITY.md
`

return new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' } })
}
12 changes: 11 additions & 1 deletion app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import Link from "next/link";
import { ArticleBody } from "@/components/content/article-body";
import { formatDate } from "@/components/content/format-date";
import { Button, Eyebrow, container } from "@/components/site/page-kit";
import { SITE_NAME, blogPostingJsonLd, excerptOf, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo";
import { SITE_NAME, blogPostingJsonLd, breadcrumbJsonLd, excerptOf, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo";

const backLink =
"inline-flex min-h-11 items-center text-[15px] font-medium text-[#5C5C5C] transition-colors hover:text-[#0A0A0A]";

// Only the posts that exist. Any other address is a real 404, not a page that
// says "not found" with a 200.
export const dynamicParams = false;

export function generateStaticParams() {
const dir = path.join(process.cwd(), "content", "blog");
if (!fs.existsSync(dir)) return [];
Expand Down Expand Up @@ -102,6 +106,12 @@ export default async function BlogPost({
return (
<main className="bg-white">
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: jsonLdString(jsonLd) }} />
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: jsonLdString(breadcrumbJsonLd([{ name: "Blog", path: "/blog" }, { name: data.seoTitle ?? data.title, path: `/blog/${slug}` }])),
}}
/>
<div className={`${container} pb-20 pt-8 md:pb-24`}>
<Link href="/blog" className={backLink}>
<span aria-hidden="true" className="mr-2">&larr;</span>
Expand Down
4 changes: 2 additions & 2 deletions app/blog/blogClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const meta = (item: Post) => [formatDate(item.date), item.readingTime].filter(Bo
function Thumb({ item, className, priority, sizes }: { item: Post; className: string; priority?: boolean; sizes: string }) {
const contain = item.imageFit === "contain";
return (
<div className={`relative overflow-hidden ${contain ? "bg-[#0A0A0A]" : "bg-[#F7F7F7]"} ${className}`}>
<div aria-hidden="true" className={`relative overflow-hidden ${contain ? "bg-[#0A0A0A]" : "bg-[#F7F7F7]"} ${className}`}>
{item.image && (
<Image
src={item.image}
alt=""
alt={item.title}
fill
priority={priority}
fetchPriority={priority ? "high" : undefined}
Expand Down
18 changes: 15 additions & 3 deletions app/dsoc/projects/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Metadata } from "next";
import { cache } from "react";

import { getDsocProject } from "@/lib/dsoc-projects";
import { pageTitle, snippetOf, withSocial } from "@/lib/seo";
import { breadcrumbJsonLd, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo";
import ProjectDetail from "./project-detail";
import { SAMPLE_PROJECTS, type Project } from "./project-data";

Expand Down Expand Up @@ -48,6 +48,18 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {

export default async function ProjectPage({ params }: Props) {
const { id } = await params;
const { project } = await loadProject(id);
return <ProjectDetail initialProject={project} />;
const { project, sample } = await loadProject(id);
const trail = project && !sample
? breadcrumbJsonLd([
{ name: "DSOC", path: "/dsoc" },
{ name: "Projects", path: "/dsoc/projects" },
{ name: project.title, path: `/dsoc/projects/${id}` },
])
: null;
return (
<>
{trail && <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: jsonLdString(trail) }} />}
<ProjectDetail initialProject={project} />
</>
);
}
9 changes: 7 additions & 2 deletions app/feed/feed-wall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,15 @@ export function FeedWall({
<span className="hidden sm:inline"> tagged #DevWeekends</span>
</span>
</p>
<a href="/api/feed/export" rel="nofollow" className={`inline-flex min-h-11 shrink-0 items-center gap-2 rounded-xl px-2 ${text.label} can-hover:text-[#0A0A0A] ${focus}`}>
{/* A button, not a link: the export address is behind robots.txt, and a link sends crawlers to it */}
<button
type="button"
onClick={() => window.location.assign("/api/feed/export")}
className={`inline-flex min-h-11 shrink-0 items-center gap-2 rounded-xl px-2 ${text.label} can-hover:text-[#0A0A0A] ${focus}`}
>
<Download className="h-4 w-4" aria-hidden="true" />
Export CSV
</a>
</button>
</div>

{shown.length === 0 ? (
Expand Down
12 changes: 11 additions & 1 deletion app/guides/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Metadata } from "next";
import { ArticleBody } from "@/components/content/article-body";
import { formatDate } from "@/components/content/format-date";
import { Button, Eyebrow, container } from "@/components/site/page-kit";
import { blogPostingJsonLd, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo";
import { blogPostingJsonLd, breadcrumbJsonLd, jsonLdString, pageTitle, snippetOf, withSocial } from "@/lib/seo";
import { svgSize } from "@/lib/svg-size";

const guidesDir = path.join(process.cwd(), "content", "guides");
Expand All @@ -18,6 +18,10 @@ function readGuide(slug: string) {
return matter(fileContent);
}

// Only the posts that exist. Any other address is a real 404, not a page that
// says "not found" with a 200.
export const dynamicParams = false;

export function generateStaticParams() {
if (!fs.existsSync(guidesDir)) return [];
return fs
Expand Down Expand Up @@ -87,6 +91,12 @@ export default async function GuidePage({
return (
<main className="bg-white">
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: jsonLdString(jsonLd) }} />
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: jsonLdString(breadcrumbJsonLd([{ name: "Guides", path: "/guides" }, { name: data.seoTitle ?? data.title, path: `/guides/${slug}` }])),
}}
/>
<div className={`${container} pb-20 pt-8 md:pb-24`}>
<Link href="/guides" className={backLink}>
<span aria-hidden="true" className="mr-2">&larr;</span>
Expand Down
1 change: 1 addition & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default function RootLayout({
<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png" />
<link rel="manifest" href="/favicons/site.webmanifest" />
<link rel="alternate" type="application/rss+xml" href="/rss.xml" title="Dev Weekends: news, guides and blog" />
<link rel="alternate" type="text/plain" href="/llms.txt" title="LLMs.txt" />
<link rel="alternate" type="text/plain" href="/llms-full.txt" title="LLMs Full" />
<link
Expand Down
71 changes: 71 additions & 0 deletions app/rss.xml/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import fs from 'fs'
import path from 'path'
import matter from 'gray-matter'

import { SITE_NAME, SITE_URL, excerptOf } from '@/lib/seo'

// Built with the site, like the sitemap: posts and guides are read from the
// content folder, which is only there at build time.
export const dynamic = 'force-static'

type Item = { title: string; url: string; date?: Date; description?: string }

function items(folder: 'blog' | 'guides'): Item[] {
const dir = path.join(process.cwd(), 'content', folder)
if (!fs.existsSync(dir)) return []
return fs
.readdirSync(dir)
.filter((file) => file.endsWith('.md'))
.flatMap((file) => {
const { data, content } = matter(fs.readFileSync(path.join(dir, file), 'utf8'))
if (data.draft === true || !data.title) return []
const date = data.date ? new Date(data.date) : undefined
return [
{
title: String(data.title),
url: `${SITE_URL}/${folder}/${file.replace(/\.md$/, '')}`,
date: date && !Number.isNaN(date.getTime()) ? date : undefined,
description: data.description ?? excerptOf(content),
},
]
})
}

const escape = (text: string) =>
text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;')

/** RSS 2.0 feed of every post and guide, newest first */
export function GET() {
const all = [...items('blog'), ...items('guides')].sort((a, b) => (b.date?.getTime() ?? 0) - (a.date?.getTime() ?? 0))
const newest = all.find((item) => item.date)?.date

const body = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>${escape(SITE_NAME)}: news, guides and blog</title>
<link>${SITE_URL}/blog</link>
<atom:link href="${SITE_URL}/rss.xml" rel="self" type="application/rss+xml" />
<description>News, practical guides and stories from Dev Weekends.</description>
<language>en</language>${newest ? `\n <lastBuildDate>${newest.toUTCString()}</lastBuildDate>` : ''}
${all
.map(
(item) => ` <item>
<title>${escape(item.title)}</title>
<link>${item.url}</link>
<guid isPermaLink="true">${item.url}</guid>${item.date ? `\n <pubDate>${item.date.toUTCString()}</pubDate>` : ''}${
item.description ? `\n <description>${escape(item.description)}</description>` : ''
}
</item>`
)
.join('\n')}
</channel>
</rss>
`

return new Response(body, {
headers: {
'Content-Type': 'application/rss+xml; charset=utf-8',
'Cache-Control': 'public, max-age=3600, stale-while-revalidate=86400',
},
})
}
8 changes: 6 additions & 2 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import matter from 'gray-matter'
import { MetadataRoute } from 'next'

import { listDsocProjects } from '@/lib/dsoc-projects'
import pageDates from '@/lib/page-dates.json'
import { SITE_URL } from '@/lib/seo'

const baseUrl = SITE_URL
Expand Down Expand Up @@ -71,10 +72,13 @@ function contentEntries(folder: 'blog' | 'guides', priority: number): MetadataRo
// folder, which exists while the site is built but not where pages are rendered
// later, so a sitemap rebuilt on a timer loses them.
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
// Static pages carry no lastModified: claiming every page changed "now" on each
// build tells search engines nothing. Posts and guides use their real dates.
// A page's date is when its own source last changed, from git history
// (scripts/page-dates.mjs). Never "now": claiming every page changed on each
// build tells search engines nothing. Posts and guides use their own dates.
const dates: Record<string, string> = pageDates
const staticPages = pages.map((entry) => ({
url: `${baseUrl}${entry.path}`,
lastModified: dates[entry.path || '/'] ? new Date(dates[entry.path || '/']) : undefined,
changeFrequency: entry.changeFrequency,
priority: entry.priority,
}))
Expand Down
11 changes: 9 additions & 2 deletions components/home/logo-mark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export function LogoMark({
return <span className={`font-semibold tracking-[-0.01em] ${compact ? "text-[10px] leading-tight sm:text-sm" : ""}`}>{org.name}</span>
}
const [width, height] = LOGO_SIZES[org.logo] ?? []
const alt = org.iconOnly ? "" : org.name
// Every logo carries the organisation's name. An icon-only mark also has the
// name printed next to it (hidden on phones in the compact grid); that printed
// copy is hidden from screen readers, so the name is heard once.
const alt = org.name
const className = `${compact ? (org.tall ? COMPACT_TALL : COMPACT) : (org.tall ? TALL : SIZES)[size]} w-auto object-contain brightness-0 transition duration-200 group-hover:scale-105 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:group-hover:scale-100 ${muted ? "opacity-60" : "opacity-90"}`
// A PNG goes through the image optimizer, asked for at the size it is shown,
// so each screen gets a file that fits it. SVG scales by itself.
Expand All @@ -84,7 +87,11 @@ export function LogoMark({
// eslint-disable-next-line @next/next/no-img-element
<img src={org.logo} alt={alt} width={width} height={height} loading="lazy" decoding="async" className={className} />
)}
{org.iconOnly && <span className={`font-semibold tracking-[-0.01em] ${compact ? "hidden md:inline" : ""}`}>{org.name}</span>}
{org.iconOnly && (
<span aria-hidden="true" className={`font-semibold tracking-[-0.01em] ${compact ? "hidden md:inline" : ""}`}>
{org.name}
</span>
)}
</span>
)
}
43 changes: 33 additions & 10 deletions components/home/sections-top.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Image from "next/image"
import { preload } from "react-dom"
import { ArrowUpRight } from "lucide-react"

import { CountUp } from "./count-up"
Expand All @@ -20,6 +21,14 @@ import {
const eyebrow = "text-[13px] font-semibold uppercase tracking-[0.14em] text-[#5C5C5C]"
const h2 = "mt-3.5 text-[clamp(36px,4.4vw,56px)] font-semibold leading-[1.05] tracking-[-0.04em]"

// The hero photo is the largest thing on the page for many visitors. It is
// served as ready-made files in three widths, straight from the edge cache.
// Resizing it on demand meant that the first visitor after a quiet spell
// waited seconds for the image service to fetch and convert it.
const HERO = "/images/hero/community-session"
const heroSet = (format: string) => [480, 768, 1080].map((width) => `${HERO}-${width}.${format} ${width}w`).join(", ")
const heroSizes = "(min-width: 1024px) 520px, 100vw"

const faces = [
{ src: "/saqlain.jpg", alt: "Muhammad Saqlain" },
{ src: "/salman.jpg", alt: "M Salman" },
Expand All @@ -28,6 +37,15 @@ const faces = [
]

export function Hero() {
// Fetch it early and ahead of other images, in the format the browser prefers
preload(`${HERO}-768.avif`, {
as: "image",
type: "image/avif",
imageSrcSet: heroSet("avif"),
imageSizes: heroSizes,
fetchPriority: "high",
})

return (
<section id="top" className="px-6 pt-2">
<div className="mx-auto max-w-[1392px] overflow-hidden rounded-[28px] bg-[#0A0A0A] text-white">
Expand Down Expand Up @@ -69,7 +87,7 @@ export function Hero() {
<Image
key={face.src}
src={face.src}
alt=""
alt={face.alt}
width={40}
height={40}
className={`h-10 w-10 rounded-full border-2 border-[#0A0A0A] object-cover grayscale transition-[filter] duration-500 hover:grayscale-0 ${index > 0 ? "-ml-2.5" : ""}`}
Expand All @@ -85,15 +103,20 @@ export function Hero() {

<div className="min-w-0 flex-[1_1_440px]">
<div className="group relative aspect-[5/4] overflow-hidden rounded-[20px] bg-[#1A1A1A]">
<Image
src="https://res.cloudinary.com/dcrgvq3lf/image/upload/v1748606356/about_img_lcygp4.jpg"
alt="Dev Weekends community members at a live session"
fill
sizes="(min-width: 1024px) 520px, 100vw"
priority
fetchPriority="high"
className="object-cover grayscale transition-[filter] duration-500 group-hover:grayscale-0"
/>
<picture>
<source type="image/avif" srcSet={heroSet("avif")} sizes={heroSizes} />
<source type="image/webp" srcSet={heroSet("webp")} sizes={heroSizes} />
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={`${HERO}-768.jpg`}
alt="Dev Weekends community members at a live session"
width={1080}
height={864}
fetchPriority="high"
decoding="async"
className="absolute inset-0 h-full w-full object-cover grayscale transition-[filter] duration-500 group-hover:grayscale-0"
/>
</picture>
<div className="absolute bottom-6 left-6 rounded-[14px] bg-white px-5 py-4 text-[#0A0A0A]">
<p className="text-[15px] font-semibold">Built in Pakistan. Gone global.</p>
<p className="mt-0.5 text-[13px] text-[#5C5C5C]">Members across 30 countries</p>
Expand Down
4 changes: 2 additions & 2 deletions components/home/voices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ export function VoicesRail() {
(video.preview.startsWith("https://img.youtube.com/") ? (
// YouTube sends its thumbnails with a two hour cache and as JPEG.
// Through the image optimizer they are resized, modern format and cached for a month.
<Image src={video.preview} alt="" fill sizes="360px" className={previewClass} />
<Image src={video.preview} alt={`${video.name}: video story`} fill sizes="360px" className={previewClass} />
) : (
// A preview set by hand can be on any host, so it is used as it is
// eslint-disable-next-line @next/next/no-img-element
<img src={video.preview} alt="" loading="lazy" decoding="async" className={previewClass} />
<img src={video.preview} alt={`${video.name}: video story`} loading="lazy" decoding="async" className={previewClass} />
))}
<span className="relative flex h-14 w-14 items-center justify-center rounded-full bg-white text-[#0A0A0A] shadow-lg">
<Play className="ml-0.5 h-5 w-5 fill-current" aria-hidden="true" />
Expand Down
2 changes: 1 addition & 1 deletion components/testimonial-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function TestimonialCard({ testimonial }: { testimonial: Testimonial }) {
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={thumbnailUrl}
alt=""
alt={`${testimonial.name}: video story`}
loading="lazy"
decoding="async"
className="absolute inset-0 h-full w-full object-cover opacity-80 grayscale transition group-hover:opacity-100 group-hover:grayscale-0 motion-reduce:transition-none"
Expand Down
Loading
Loading