Skip to content

Commit

Permalink
fix: use data from @betagouv/aides-velo instead of local communes.jso…
Browse files Browse the repository at this point in the history
…n file
  • Loading branch information
EmileRolley committed Nov 6, 2024
1 parent 442d9ed commit 7468488
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions retrofit/routes/api/ville/+server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import data from '$lib/data/communes.json';
import { data } from '@betagouv/aides-velo';
import { error } from '@sveltejs/kit';
import { rawCityToFullLocalisation } from '$lib/utils';

export function GET({ url }) {
const slug = url.searchParams.get('slug');
const ville = data.find((v) => v.slug === slug);
const ville = data.communes.find((v) => v.slug === slug);
if (!ville) {
error(404);
}
Expand Down
6 changes: 4 additions & 2 deletions src/routes/(front)/sitemap.txt/+server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import communes from '$lib/data/communes.json';
import { data } from '@betagouv/aides-velo';
import { _departementWithSlug } from '../departement/[slug]/+page.server';

/** @type {import('./$types').RequestHandler} */
Expand All @@ -10,7 +10,9 @@ export async function GET() {
'/forfait-mobilite-durable',
'/liste-aides',
..._departementWithSlug.map(({ slug }) => `/departement/${slug}`),
...communes.sort((a, b) => b.population - a.population).map(({ slug }) => `/ville/${slug}`),
...data.communes
.sort((a, b) => b.population - a.population)
.map(({ slug }) => `/ville/${slug}`),
]
.map((path) => `https://mesaidesvelo.fr${path}`)
.join('\n'),
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/collectivites/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// l'utilisateur.

import { rawCityToFullLocalisation, removeAccents } from '$lib/utils';
import { data } from '@betagouv/aides-velo';
import fuzzysort from 'fuzzysort';
import data from '$lib/data/communes.json';

const indexedData = data.flatMap(({ codesPostaux, ...rest }) =>
const indexedData = data.communes.flatMap(({ codesPostaux, ...rest }) =>
codesPostaux.map((codePostal, i) => {
const cpPrincipal = i === 0;
return {
Expand Down

0 comments on commit 7468488

Please sign in to comment.