perf: apply Vercel React best practices (async-parallel and server-serialization)
This commit is contained in:
@@ -37,18 +37,21 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|||||||
|
|
||||||
export default async function ServiceLocationPage({ params }: Props) {
|
export default async function ServiceLocationPage({ params }: Props) {
|
||||||
const { slug, location: locationSlug } = await params;
|
const { slug, location: locationSlug } = await params;
|
||||||
const [service, location, settings] = await Promise.all([
|
|
||||||
getServiceBySlug(slug),
|
// Vercel Best Practice: async-parallel - Fetch independent operations in parallel
|
||||||
|
const service = await getServiceBySlug(slug);
|
||||||
|
if (!service) notFound();
|
||||||
|
|
||||||
|
const [location, settings, projects] = await Promise.all([
|
||||||
getLocationBySlug(locationSlug),
|
getLocationBySlug(locationSlug),
|
||||||
getSettings()
|
getSettings(),
|
||||||
|
getProjectsByService(service.title)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!service || !location) {
|
if (!location) {
|
||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const projects = await getProjectsByService(service.title);
|
|
||||||
|
|
||||||
const breadcrumbLd = {
|
const breadcrumbLd = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "BreadcrumbList",
|
"@type": "BreadcrumbList",
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ export async function generateMetadata(): Promise<Metadata> {
|
|||||||
|
|
||||||
export default async function ServicesPage() {
|
export default async function ServicesPage() {
|
||||||
const [services, locations] = await Promise.all([
|
const [services, locations] = await Promise.all([
|
||||||
sql`SELECT * FROM services ORDER BY display_order ASC`,
|
// Vercel Best Practice: server-serialization - Select only required fields
|
||||||
sql`SELECT * FROM locations ORDER BY display_order ASC`
|
sql`SELECT id, title, description, slug, icon_name, sub_services FROM services ORDER BY display_order ASC`,
|
||||||
|
sql`SELECT id, name, slug FROM locations ORDER BY display_order ASC`
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const servicesSchema = {
|
const servicesSchema = {
|
||||||
|
|||||||
Reference in New Issue
Block a user