diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 104f923f..23c69941 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,7 @@ jobs: - name: Build website env: BASE_PATH: '/${{ github.event.repository.name }}' + PUBLIC_MAPBOX_TOKEN: ${{ secrets.PUBLIC_MAPBOX_TOKEN }} run: | npm run build --prefix website diff --git a/website/.env.example b/website/.env.example new file mode 100644 index 00000000..4d6b95bd --- /dev/null +++ b/website/.env.example @@ -0,0 +1 @@ +PUBLIC_MAPBOX_TOKEN=YOUR_MAPBOX_TOKEN \ No newline at end of file diff --git a/website/src/lib/assets/layers.ts b/website/src/lib/assets/layers.ts index 1207a78b..03c4f17b 100644 --- a/website/src/lib/assets/layers.ts +++ b/website/src/lib/assets/layers.ts @@ -1,7 +1,6 @@ +import { PUBLIC_MAPBOX_TOKEN } from '$env/static/public'; import { type AnySourceData, type Style } from 'mapbox-gl'; -export const mapboxAccessToken = 'pk.eyJ1IjoidmNvcHBlIiwiYSI6ImNseG0zNHpwdTA1NXUycXF4ejJyODc0NWQifQ.4tiCPQ1SxnYl4o7aQc89VA'; - export const basemaps: { [key: string]: string | Style; } = { mapboxOutdoors: 'mapbox://styles/mapbox/outdoors-v12', mapboxSatellite: 'mapbox://styles/mapbox/satellite-streets-v12', @@ -269,7 +268,7 @@ export const basemaps: { [key: string]: string | Style; } = { export function extendBasemap(basemap: string | Style): string | Style { if (typeof basemap === 'object') { basemap["glyphs"] = "mapbox://fonts/mapbox/{fontstack}/{range}.pbf"; - basemap["sprite"] = `https://api.mapbox.com/styles/v1/mapbox/outdoors-v12/sprite?access_token=${mapboxAccessToken}`; + basemap["sprite"] = `https://api.mapbox.com/styles/v1/mapbox/outdoors-v12/sprite?access_token=${PUBLIC_MAPBOX_TOKEN}`; } return basemap; } diff --git a/website/src/lib/components/Map.svelte b/website/src/lib/components/Map.svelte index 0140a941..bf1c3a20 100644 --- a/website/src/lib/components/Map.svelte +++ b/website/src/lib/components/Map.svelte @@ -11,12 +11,13 @@ import { settings } from '$lib/db'; import { locale } from 'svelte-i18n'; import { get } from 'svelte/store'; - import { mapboxAccessToken } from '$lib/assets/layers'; - - mapboxgl.accessToken = mapboxAccessToken; + import { PUBLIC_MAPBOX_TOKEN } from '$env/static/public'; + export let accessToken = PUBLIC_MAPBOX_TOKEN; export let geocoder = true; + mapboxgl.accessToken = accessToken; + let fitBoundsOptions: mapboxgl.FitBoundsOptions = { maxZoom: 15, linear: true, diff --git a/website/src/lib/components/Nav.svelte b/website/src/lib/components/Nav.svelte index 09e3c8f7..efefc824 100644 --- a/website/src/lib/components/Nav.svelte +++ b/website/src/lib/components/Nav.svelte @@ -7,7 +7,7 @@ import { getURLForLanguage } from '$lib/utils'; -