chore: add version indicator and finalize map/carousel
This commit is contained in:
parent
74f4853686
commit
5eed471ad9
3 changed files with 23 additions and 6 deletions
|
|
@ -1,7 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useI18n } from '../components/I18nProvider';
|
||||
|
||||
|
|
@ -48,10 +47,23 @@ function haversineKm(a: LatLng, b: LatLng) {
|
|||
return 2 * R * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));
|
||||
}
|
||||
|
||||
const LeafletWrapper = dynamic(async () => {
|
||||
const L = await import('leaflet');
|
||||
return L;
|
||||
}, { ssr: false });
|
||||
type LeafletLib = typeof import('leaflet');
|
||||
|
||||
async function loadLeaflet(): Promise<LeafletLib> {
|
||||
if (typeof window === 'undefined') return Promise.reject(new Error('No window'));
|
||||
if ((window as any).L) return (window as any).L as LeafletLib;
|
||||
const linkId = 'leaflet-css';
|
||||
if (!document.getElementById(linkId)) {
|
||||
const link = document.createElement('link');
|
||||
link.id = linkId;
|
||||
link.rel = 'stylesheet';
|
||||
link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
const mod: LeafletLib = await import('leaflet');
|
||||
(window as any).L = mod;
|
||||
return mod;
|
||||
}
|
||||
|
||||
function ListingsMap({
|
||||
listings,
|
||||
|
|
@ -74,7 +86,7 @@ function ListingsMap({
|
|||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
LeafletWrapper
|
||||
loadLeaflet()
|
||||
.then((L) => {
|
||||
if (cancelled) return;
|
||||
setReady(true);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export default function HomePage() {
|
|||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000';
|
||||
const apiBase = process.env.NEXT_PUBLIC_API_BASE || 'http://localhost:3000/api';
|
||||
const appEnv = process.env.APP_ENV || 'local';
|
||||
const appVersion = process.env.NEXT_PUBLIC_VERSION || 'dev';
|
||||
const [latest, setLatest] = useState<LatestListing[]>([]);
|
||||
const [activeIndex, setActiveIndex] = useState(0);
|
||||
const [loadingLatest, setLoadingLatest] = useState(false);
|
||||
|
|
@ -108,6 +109,9 @@ export default function HomePage() {
|
|||
<span>
|
||||
<strong>{t('runtimeApiBase')}</strong> <code>{apiBase}</code>
|
||||
</span>
|
||||
<span>
|
||||
<strong>Version</strong> <code>{appVersion}</code>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ data:
|
|||
NEXT_PUBLIC_SITE_URL: ${NEXT_PUBLIC_SITE_URL}
|
||||
NEXT_PUBLIC_API_BASE: ${NEXT_PUBLIC_API_BASE}
|
||||
APP_ENV: ${APP_ENV}
|
||||
NEXT_PUBLIC_VERSION: ${APP_VERSION}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue