-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56ba1b3
commit ca196ff
Showing
14 changed files
with
167 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
58 changes: 58 additions & 0 deletions
58
frontend/app/[locale]/vehicles/[vehicle_id]/opengraph-image.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* * */ | ||
|
||
import fs from 'fs'; | ||
import { ImageResponse } from 'next/og'; | ||
import OpenGraphStopsDefault from 'opengraph/OpenGraphStopsDefault'; | ||
import OpenGraphStopsDynamic from 'opengraph/OpenGraphStopsDynamic'; | ||
|
||
/* * */ | ||
|
||
export const alt = 'Mais sobre esta paragem'; | ||
export const size = { width: 1200, height: 630 }; | ||
export const contentType = 'image/png'; | ||
|
||
/* * */ | ||
|
||
export default async function Image({ params }) { | ||
// | ||
|
||
// | ||
// A. Setup fonts | ||
|
||
const customFonts = [ | ||
{ name: 'Inter', style: 'normal', weight: 500, data: fs.readFileSync(`${process.cwd()}/assets/fonts/Inter-Medium.ttf`).buffer }, | ||
{ name: 'Inter', style: 'normal', weight: 600, data: fs.readFileSync(`${process.cwd()}/assets/fonts/Inter-SemiBold.ttf`).buffer }, | ||
{ name: 'Inter', style: 'normal', weight: 700, data: fs.readFileSync(`${process.cwd()}/assets/fonts/Inter-Bold.ttf`).buffer }, | ||
]; | ||
|
||
// | ||
// B. Fetch data | ||
|
||
const stopData = await fetch(params.stop_id?.length && `https://api.carrismetropolitana.pt/stops/${params.stop_id}`).then((res) => res.json()); | ||
|
||
// | ||
// C. Render default component | ||
|
||
if (params.stop_id === 'all' || !stopData?.id) { | ||
return new ImageResponse(<OpenGraphStopsDefault />, { ...size, fonts: customFonts }); | ||
} | ||
|
||
// - - - | ||
|
||
// | ||
// D. Fetch additional data | ||
|
||
const allLinesData = []; | ||
|
||
for (const lineId of stopData.lines) { | ||
const lineData = await fetch(`https://api.carrismetropolitana.pt/lines/${lineId}`).then((res) => res.json()); | ||
allLinesData.push(lineData); | ||
} | ||
|
||
// | ||
// E. Render dynamic component | ||
|
||
return new ImageResponse(<OpenGraphStopsDynamic stopData={stopData} allLinesData={allLinesData} />, { ...size, fonts: customFonts }); | ||
|
||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* * */ | ||
|
||
import { OneFullColumn } from '@/components/Layouts/Layouts'; | ||
import { StopsExplorerContextProvider } from '@/contexts/StopsExplorerContext'; | ||
import StopsExplorer from '@/components/StopsExplorer/StopsExplorer'; | ||
|
||
/* * */ | ||
|
||
export async function generateMetadata({ params }) { | ||
// | ||
|
||
// A. Fetch stop data | ||
const stopData = await fetch(params.stop_id?.length && `https://api.carrismetropolitana.pt/stops/${params.stop_id}`).then((res) => res.json()); | ||
|
||
// B. Render the titles | ||
if (params.stop_id === 'all' || !stopData.name) { | ||
switch (params.locale) { | ||
case 'pt': | ||
return { title: 'Todas as Paragens', description: 'Conheça as paragens e horários da Carris Metropolitana' }; | ||
default: | ||
case 'en': | ||
return { title: 'Todas as Paragens', description: 'Conheça as paragens e horários da Carris Metropolitana' }; | ||
} | ||
} else { | ||
switch (params.locale) { | ||
case 'pt': | ||
return { title: `Horários na paragem ${stopData.name}`, description: 'Estimativas de chegada em tempo real para os autocarros da Carris Metropolitana nesta paragem.' }; | ||
default: | ||
case 'en': | ||
return { title: `Horários na paragem ${stopData.name}`, description: 'Estimativas de chegada em tempo real para os autocarros da Carris Metropolitana nesta paragem.' }; | ||
} | ||
} | ||
|
||
// | ||
} | ||
|
||
/* * */ | ||
|
||
export default function Page() { | ||
// | ||
|
||
// | ||
// A. Render components | ||
|
||
return ( | ||
<OneFullColumn> | ||
<StopsExplorerContextProvider> | ||
<StopsExplorer /> | ||
</StopsExplorerContextProvider> | ||
</OneFullColumn> | ||
); | ||
|
||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/* * */ | ||
|
||
import Loader from '@/components/Loader/Loader'; | ||
|
||
/* * */ | ||
|
||
export default function Loading() { | ||
return <Loader visible full />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// | ||
/* * */ | ||
|
||
export default async function sitemap() { | ||
// | ||
|