Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/basic/src/app/appRouting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { SamplePageLayout } from '../components/SamplePageLayout';
import { getLanguageFromPath } from '../samples/i18n';
import { DEFAULT_SAMPLE_PAGE, isKnownSamplePage, isSupportedLanguage, resolveProviderForPage, type SupportedLanguage } from '../samples/sampleRegistry';

export type MapProvider = 'maplibre' | 'mapbox' | 'leaflet' | 'openlayers' | 'google' | 'google-3d' | 'arcgis' | 'arcgis-3d' | 'mapkit' | 'azuremaps' | 'cesium' | 'here' | 'tomtom' | 'maptiler' | 'longdo' | 'mappls' | 'deckgl';
export const MAP_PROVIDERS = [
'maplibre', 'mapbox', 'leaflet', 'openlayers', 'google', 'google-3d', 'arcgis', 'arcgis-3d', 'mapkit', 'azuremaps', 'cesium', 'here', 'tomtom', 'maptiler', 'longdo', 'mappls', 'deckgl',
] as const;

export type MapProvider = typeof MAP_PROVIDERS[number];

const providerByPath = new Map<string, MapProvider>([
['maplibre', 'maplibre'], ['maplibre-3d', 'maplibre'], ['mapbox', 'mapbox'],
Expand Down
24 changes: 6 additions & 18 deletions examples/basic/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { renderToString } from 'react-dom/server';
import { StaticRouter } from 'react-router-dom';
import App from './App';
import { MAP_PROVIDERS, providerPath } from './app/appRouting';
import {
DEFAULT_SAMPLE_PAGE,
getSamplePageMetadata,
resolveProviderForPage,
SAMPLE_PAGES,
SUPPORTED_LANGUAGES,
type SupportedLanguage,
Expand Down Expand Up @@ -36,27 +36,15 @@ export function getDocumentMetadata(url: string): {
}

export function getStaticPaths(): string[] {
const providers = [
'mapbox',
'leaflet',
'openlayers',
'arcgis',
'arcgis-3d',
'mapkit',
'azuremaps',
'cesium',
'here',
'google-maps',
'google-maps-3d',
];
const languages: readonly SupportedLanguage[] = SUPPORTED_LANGUAGES;
// Every provider's pages are prerendered: a path without its own file falls
// back to /index.html (the MapLibre page), and the client then fails to
// hydrate it (React #418).
const providerPages = SAMPLE_PAGES
.filter(page => page.id !== 'camera-sync')
.flatMap(page => {
const mapLibreProvider = resolveProviderForPage('maplibre', page.id);
return [mapLibreProvider, ...providers].flatMap(provider =>
languages.map(language => `/${provider}/${page.id}/${language}`),
);
const paths = new Set(MAP_PROVIDERS.map(provider => providerPath(provider, page.id)));
return [...paths].flatMap(path => languages.map(language => `/${path}/${page.id}/${language}`));
});
return [
...providerPages,
Expand Down
Loading