Skip to content

Commit

Permalink
feat: add trip page
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-giret committed Mar 8, 2024
1 parent e510521 commit 46843c2
Show file tree
Hide file tree
Showing 17 changed files with 690 additions and 56 deletions.
44 changes: 44 additions & 0 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/
*/

import path from 'path';

import { CreatePagesArgs } from 'gatsby';

import { trips } from './src/fixtures/trips';

export async function createPages({ actions, graphql }: CreatePagesArgs) {
const { createPage } = actions;

const { data } = await graphql<Queries.CreatePagesQuery>(`
query CreatePages {
allFile {
nodes {
id
relativePath
}
}
}
`);

trips.forEach(({ key, coverImage, steps }, tripIndex) => {
const stepPhotosPaths = steps.flatMap(({ photos }) => photos.flatMap(({ path }) => path));
const files =
data?.allFile.nodes.filter(
({ relativePath }) => relativePath === coverImage || stepPhotosPaths.includes(relativePath),
) || [];

createPage({
path: `/${key}`,
component: path.resolve(`src/pages/trip/index.tsx`),
context: {
tripIndex,
queryImages: files.length > 0,
imageIds: files.map(({ id }) => id),
},
});
});
}
1 change: 1 addition & 0 deletions src/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './trips';
80 changes: 80 additions & 0 deletions src/fixtures/trips/22-lav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const lav22Trip: TTrip = {
key: 'lav22',
title: 'Loire à Vélo',
coverImage: 'trips/22-lav/cover.jpg',
coverImageDescription: 'La Loire, Saumur et son château',
color: '#174589',
themes: ['nature', 'heritage', 'gastronomy'],
from: 'Tours',
Expand All @@ -23,34 +24,113 @@ export const lav22Trip: TTrip = {
date: new Date('2022-06-13'),
distance: 42.8,
geometry: step1,
photos: [
{
path: 'trips/22-lav/step-1/PXL_20220613_091927509.MP.jpg',
description: 'Un panneau de direction de la Loire à Vélo',
},
{
path: 'trips/22-lav/step-1/PXL_20220613_093615601.jpg',
description: 'La confluence de la Loire et du Cher',
},
{
path: 'trips/22-lav/step-1/PXL_20220613_115513025.jpg',
description: "Petite pause sieste près d'un lac à Langeais",
},
{
path: 'trips/22-lav/step-1/PXL_20220613_162505397.jpg',
description:
"Le château d'Ussé, aussi connu comme étant le château de la Belle au Bois Dormant",
},
],
},
{
from: 'Rigny-Ussé',
to: 'Saumur',
date: new Date('2022-06-14'),
distance: 43.7,
geometry: step2,
photos: [
{
path: 'trips/22-lav/step-2/PXL_20220614_084617076.jpg',
description: 'Le village de Candes-Saint-Martin, un des plus beaux de France',
},
{
path: 'trips/22-lav/step-2/PXL_20220614_091354350.jpg',
description: 'La confluence de la Loire et de la Vienne',
},
{
path: 'trips/22-lav/step-2/PXL_20220614_121336592.jpg',
description: "L'abbaye Royale de Fontevraud",
},
{
path: 'trips/22-lav/step-2/PXL_20220614_135613603.jpg',
description: 'La Loire et ses larges bandes de sable',
},
{
path: 'trips/22-lav/step-2/PXL_20220614_152957352.jpg',
description: 'La Loire, Saumur et son château',
},
],
},
{
from: 'Saumur',
to: 'Angers',
date: new Date('2022-06-15'),
distance: 59.8,
geometry: step3,
photos: [
{
path: 'trips/22-lav/step-3/PXL_20220615_090819541.jpg',
description: 'Le château de Saumur',
},
{
path: 'trips/22-lav/step-3/PXL_20220615_091223813.MP.jpg',
description: 'La Loire vue depuis le château de Saumur',
},
{
path: 'trips/22-lav/step-3/PXL_20220615_154149422.MP.jpg',
description: "Un bac à chaîne sur L'Authion, à Trélazé",
},
],
},
{
from: 'Angers',
to: 'Ancenis',
date: new Date('2022-06-16'),
distance: 70.2,
geometry: step4,
photos: [
{
path: 'trips/22-lav/step-4/PXL_20220616_075321827.jpg',
description: 'La Loire, Angers et son château',
},
{
path: 'trips/22-lav/step-4/PXL_20220616_090427991.jpg',
description: 'Une ruelle du village de Béhuard, classé village de caractère',
},
{
path: 'trips/22-lav/step-4/PXL_20220616_160424769.jpg',
description: "Le château d'Ancenis",
},
],
},
{
from: 'Ancenis',
to: 'Nantes',
date: new Date('2022-06-17'),
distance: 42.8,
geometry: step5,
photos: [
{
path: 'trips/22-lav/step-5/PXL_20220617_092234575.MP.jpg',
description: 'Le château des Ducs de Bretagne à Nantes',
},
{
path: 'trips/22-lav/step-5/PXL_20220617_100633964.MP.jpg',
description: 'La cour du château des Ducs de Bretagne à Nantes',
},
],
},
],
};
83 changes: 82 additions & 1 deletion src/fixtures/trips/23-velo-francette/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const veloFrancette23Trip: TTrip = {
key: 'veloFrancette23',
title: 'Vélo Francette',
coverImage: 'trips/23-velo-francette/cover.jpg',
coverImageDescription: 'Le Marais Poitevin ou coulée verte',
color: '#e5004b',
themes: ['nature'],
from: 'Chinon',
Expand All @@ -23,28 +24,108 @@ export const veloFrancette23Trip: TTrip = {
geometry: step1,
from: 'Chinon',
to: 'Thouars',
photos: [
{
path: 'trips/23-velo-francette/step-1/PXL_20230520_102916760.jpg',
description: 'Notre chargement avant le départ',
},
{
path: 'trips/23-velo-francette/step-1/PXL_20230520_120447928.jpg',
description: 'Des vignes près de Chinon',
},
{
path: 'trips/23-velo-francette/step-1/PXL_20230520_140619639.jpg',
description: 'La ville de Thouars et son château',
},
],
},
{
date: new Date('2023-05-21'),
distance: 47.7,
geometry: step2,
from: 'Thouars',
to: 'Parthenay',
photos: [
{
path: 'trips/23-velo-francette/step-2/PXL_20230521_124858869.MP.jpg',
description: 'Une voie verte entre Thouars et Parthenay',
},
{
path: 'trips/23-velo-francette/step-2/PXL_20230521_132328075.jpg',
description: 'Une rue de la ville de Parthenay',
},
{
path: 'trips/23-velo-francette/step-2/PXL_20230521_134522260.jpg',
description: 'Vue sur Parthenay depuis son château',
},
{
path: 'trips/23-velo-francette/step-2/PXL_20230521_141818306.jpg',
description: 'La ville de Parthenay et ses ruines',
},
],
},
{
date: new Date('2023-05-22'),
distance: 55.8,
geometry: step3,
from: 'Parthenay',
to: 'Niort',
photos: [
{
path: 'trips/23-velo-francette/step-3/PXL_20230522_082022913.jpg',
description: 'Passage sur un ponton',
},
{
path: 'trips/23-velo-francette/step-3/PXL_20230522_092527795.MP.jpg',
description: 'Une voie verte entre Parthenay et Niort',
},
],
},
{
date: new Date('2023-05-23'),
distance: 65,
geometry: step4,
from: 'Niort',
to: 'Marans',
photos: [
{
path: 'trips/23-velo-francette/step-4/PXL_20230523_101540418.jpg',
description: 'Pont étroit en sortie de Niort',
},
{
path: 'trips/23-velo-francette/step-4/PXL_20230523_125411619.MP.jpg',
description: 'La Sèvre Niortaise, au cœur du Marais Poitevin ou coulée verte',
},
{
path: 'trips/23-velo-francette/step-4/PXL_20230523_130558353.jpg',
description: 'Une écluse sur la Sèvre Niortaise',
},
{
path: 'trips/23-velo-francette/step-4/PXL_20230523_130843494.jpg',
description: 'La Sèvre Niortaise, au cœur du Marais Poitevin ou coulée verte',
},
],
},
{ date: new Date('2023-05-23'), distance: 65, geometry: step4, from: 'Niort', to: 'Marans' },
{
date: new Date('2023-05-24'),
distance: 27.6,
geometry: step5,
from: 'Marans',
to: 'La Rochelle',
photos: [
{
path: 'trips/23-velo-francette/step-5/PXL_20230524_085147080.jpg',
description: 'La ville de Marans',
},
{
path: 'trips/23-velo-francette/step-5/PXL_20230524_124556478.jpg',
description: 'Les tours sur le port de La Rochelle',
},
{
path: 'trips/23-velo-francette/step-5/PXL_20230526_094008720.jpg',
description: "Reconstitution d'un bateau d'époque coloniale sur le port de La Rochelle",
},
],
},
],
};
73 changes: 73 additions & 0 deletions src/fixtures/trips/23-velodyssee/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const velodyssee23Trip: TTrip = {
key: 'velodyssee23',
title: 'La Vélodyssée',
coverImage: 'trips/23-velodyssee/cover.jpg',
coverImageDescription: "Le passage du Gois, entre l'île de Noirmoutier et le continent",
color: '#f59c00',
themes: ['nature', 'littoral'],
from: 'Luçon',
Expand All @@ -23,27 +24,99 @@ export const velodyssee23Trip: TTrip = {
geometry: step1,
from: 'Luçon',
to: 'Jard-sur-Mer',
photos: [
{
path: 'trips/23-velodyssee/step-1/PXL_20230526_105648489.jpg',
description: 'Notre chargement dans le train avant le départ',
},
{
path: 'trips/23-velodyssee/step-1/PXL_20230526_134730054.jpg',
description: 'Une voie verte entre Luçon et Jard-sur-Mer',
},
{
path: 'trips/23-velodyssee/step-1/PXL_20230526_150931600.jpg',
description: 'Le port de Saint-Vincent-sur-Jard',
},
],
},
{
date: new Date('2023-05-30'),
distance: 65.4,
geometry: step2,
from: 'Jard-sur-Mer',
to: 'Saint-Hilaire-de-Riez',
photos: [
{
path: 'trips/23-velodyssee/step-2/PXL_20230530_090827504.jpg',
description: "Vue sur l'océan entre Jard-sur-Mer et Saint-Hilaire-de-Riez",
},
{
path: 'trips/23-velodyssee/step-2/PXL_20230530_115021575.jpg',
description: 'Plage entre Jard-sur-Mer et Saint-Hilaire-de-Riez',
},
],
},
{
date: new Date('2023-05-31'),
distance: 50.5,
geometry: step3,
from: 'Saint-Hilaire-de-Riez',
to: 'La Guérinière',
photos: [
{
path: 'trips/23-velodyssee/step-3/PXL_20230531_133733012.jpg',
description: 'Voie verte dans une forêt entre Saint-Hilaire-de-Riez et la Guérinière',
},
{
path: 'trips/23-velodyssee/step-3/PXL_20230531_134247013.jpg',
description: "Pont de l'île de Noirmoutier",
},
{
path: 'trips/23-velodyssee/step-3/PXL_20230531_135525145.MP.jpg',
description: "Traversée du pont de l'île de Noirmoutier",
},
{
path: 'trips/23-velodyssee/step-3/PXL_20230531_140338874.jpg',
description: "Un oiseau dans les marais sur l'île de Noirmoutier",
},
{
path: 'trips/23-velodyssee/step-3/PXL_20230531_141557573.jpg',
description: "Passage entre océan et marais l'île de Noirmoutier",
},
{
path: 'trips/23-velodyssee/step-3/PXL_20230531_170126479.jpg',
description: "Marais sur l'île de Noirmoutier",
},
],
},
{
date: new Date('2023-06-01'),
distance: 60.1,
geometry: step4,
from: 'La Guérinière',
to: 'Pornic',
photos: [
{
path: 'trips/23-velodyssee/step-4/PXL_20230601_071221189.MP.jpg',
description: 'Traversée du passage du Gois',
},
{
path: 'trips/23-velodyssee/step-4/PXL_20230601_072115328.jpg',
description: 'Le passage du Gois',
},
{
path: '/trips/23-velodyssee/step-4/PXL_20230601_084027133.jpg',
description: "Un port coloré d'ostréiculteurs",
},
{
path: 'trips/23-velodyssee/step-4/PXL_20230601_121210461.jpg',
description: 'Le port de Pornic',
},
{
path: 'trips/23-velodyssee/step-4/PXL_20230601_171121353.jpg',
description: 'Une pêcherie près de Pornic',
},
],
},
{
date: new Date('2023-06-02'),
Expand Down
Loading

0 comments on commit 46843c2

Please sign in to comment.