PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m3s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 11s
PR Checks / Build Frontend (no push) (pull_request) Successful in 44s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Failing after 11s
The baseline says these pages already rank and are not clicked. 'compare school performance' sits at position 6.1 with 0.43% CTR; 'compare schools' at 7.2 with 0.87%. The brand query 'school compare' draws 9.16% from the same neighbourhood of the same results page, which rules out a ranking explanation — when the snippet gives a reason to click, it gets clicked. These SERPs are owned by the DfE's own 'Compare school performance' service. The old title put a lowercase brand nobody searches for in the most valuable pixels, then a near-paraphrase of that service's name. Beside the government's own result it read as a lookalike. Intent in the title, differentiator in the description. Titles now match what people type, and the descriptions carry the one fact gov.uk does not publish: how close you had to live to get a place. /compare deliberately takes the tool phrasing rather than the homepage's, so the two pages stop competing for one phrase. The root layout's default and Open Graph copy were saying something different again; they now agree. No hard school counts in any of it. The corpus moves with every data refresh and this repo has already shipped one copy bug of that kind. Tests guard the mechanics — SERP length, intent keyword, the differentiator, no brand-first title — and leave the wording free to iterate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj
87 lines
2.9 KiB
TypeScript
87 lines
2.9 KiB
TypeScript
/**
|
||
* Rankings Page (SSR)
|
||
* Display top-ranked schools by various metrics
|
||
*/
|
||
|
||
import { fetchRankings, fetchFilters, fetchMetrics } from '@/lib/api';
|
||
import { RankingsView } from '@/components/RankingsView';
|
||
import { absoluteUrl } from '@/lib/site';
|
||
import type { Metadata } from 'next';
|
||
|
||
interface RankingsPageProps {
|
||
searchParams: Promise<{
|
||
metric?: string;
|
||
local_authority?: string;
|
||
year?: string;
|
||
phase?: string;
|
||
}>;
|
||
}
|
||
|
||
export const metadata: Metadata = {
|
||
// 'School Rankings' matched nothing anyone types. League tables is the
|
||
// phrase parents actually search, and it spikes each results day.
|
||
title: { absolute: 'Primary & Secondary School League Tables | schoolcompare' },
|
||
description:
|
||
'Rank English schools by SATs results, GCSEs, Progress 8 or Attainment 8, and filter by local authority or year. Built from the DfE’s own figures.',
|
||
keywords: 'school rankings, top schools, best schools, KS2 rankings, KS4 rankings, school league tables',
|
||
// Param forms (?metric=&local_authority=&year=&phase=) collapse here for
|
||
// now. W3 replaces them with real indexable paths.
|
||
alternates: { canonical: absoluteUrl('/rankings') },
|
||
};
|
||
|
||
// Dynamic via searchParams; remove force-dynamic so internal data fetches
|
||
// can still use Next.js's per-call revalidate cache.
|
||
|
||
export default async function RankingsPage({ searchParams }: RankingsPageProps) {
|
||
const { metric: metricParam, local_authority, year: yearParam, phase: phaseParam } = await searchParams;
|
||
|
||
const phase = phaseParam || 'primary';
|
||
const metric = metricParam || (phase === 'secondary' ? 'attainment_8_score' : 'rwm_expected_pct');
|
||
const year = yearParam ? parseInt(yearParam) : undefined;
|
||
|
||
// Fetch rankings data with error handling
|
||
try {
|
||
const [rankingsResponse, filtersResponse, metricsResponse] = await Promise.all([
|
||
fetchRankings({
|
||
metric,
|
||
local_authority,
|
||
year,
|
||
limit: 100,
|
||
phase,
|
||
}),
|
||
fetchFilters(),
|
||
fetchMetrics(),
|
||
]);
|
||
|
||
// Metrics is already an array
|
||
const metricsArray = metricsResponse?.metrics || [];
|
||
|
||
return (
|
||
<RankingsView
|
||
rankings={rankingsResponse?.rankings || []}
|
||
filters={filtersResponse || { local_authorities: [], school_types: [], years: [], phases: [], genders: [], admissions_policies: [] }}
|
||
metrics={metricsArray}
|
||
selectedMetric={metric}
|
||
selectedArea={local_authority}
|
||
selectedYear={year}
|
||
selectedPhase={phase}
|
||
/>
|
||
);
|
||
} catch (error) {
|
||
console.error('Error fetching data for rankings page:', error);
|
||
|
||
// Return error state with empty data
|
||
return (
|
||
<RankingsView
|
||
rankings={[]}
|
||
filters={{ local_authorities: [], school_types: [], years: [], phases: [], genders: [], admissions_policies: [] }}
|
||
metrics={[]}
|
||
selectedMetric={metric}
|
||
selectedArea={local_authority}
|
||
selectedYear={year}
|
||
selectedPhase={phase}
|
||
/>
|
||
);
|
||
}
|
||
}
|