diff --git a/package-lock.json b/package-lock.json index 30ec0fa8..2bfb069d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@heroicons/react": "^2.0.17", "leaflet": "^1.9.4", "prop-types": "^15.8.1", - "react-helmet": "^6.1.0", "react-leaflet": "^4.2.1", "react-leaflet-cluster": "^2.1.0", "react-router-dom": "^6.16.0", @@ -3787,25 +3786,6 @@ "react": "^18.2.0" } }, - "node_modules/react-fast-compare": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", - "integrity": "sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==" - }, - "node_modules/react-helmet": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", - "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", - "dependencies": { - "object-assign": "^4.1.1", - "prop-types": "^15.7.2", - "react-fast-compare": "^3.1.1", - "react-side-effect": "^2.1.0" - }, - "peerDependencies": { - "react": ">=16.3.0" - } - }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -3868,14 +3848,6 @@ "react-dom": ">=16.8" } }, - "node_modules/react-side-effect": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.2.tgz", - "integrity": "sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==", - "peerDependencies": { - "react": "^16.3.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/react-string-replace": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/react-string-replace/-/react-string-replace-1.1.1.tgz", diff --git a/package.json b/package.json index 0e549a55..5c987ea4 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@heroicons/react": "^2.0.17", "leaflet": "^1.9.4", "prop-types": "^15.8.1", - "react-helmet": "^6.1.0", "react-leaflet": "^4.2.1", "react-leaflet-cluster": "^2.1.0", "react-router-dom": "^6.16.0", diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index bf088e55..83a07fcc 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -11,13 +11,10 @@ import { useGetItemTags } from './hooks/useTags' import { useAddMarker, useAddPopup, useLeafletRefs } from './hooks/useLeafletRefs' import { Popup } from 'leaflet' import { useLocation } from 'react-router-dom'; -import {Helmet} from "react-helmet"; export const Layer = (props: LayerProps) => { const [itemFormPopup, setItemFormPopup] = useState(null); - const [ogTitle, setOgTitle] = useState(""); - const [ogDescription, setOgDescription] = useState(""); const filterTags = useFilterTags(); @@ -52,15 +49,8 @@ export const Layer = (props: LayerProps) => { }, }) - const openPopup = () => { - console.log(window.location); - - - if (window.location.pathname.split("/").length <= 2) { - console.log("close"); - setOgTitle(""); - setOgDescription(""); + if (window.location.pathname.split("/").length <= 2 || window.location.pathname.split("/")[2]==="") { map.closePopup(); } else { @@ -74,8 +64,9 @@ export const Layer = (props: LayerProps) => { marker.openPopup(); }); const item = leafletRefs[id]?.item; - setOgTitle(item.name); - setOgDescription(item.text); + document.title = document.title.split("-")[0] + " - " + item.name; + document.querySelector('meta[property="og:title"]')?.setAttribute("content", item.name); + document.querySelector('meta[property="og:description"]')?.setAttribute("content", item.text); } } } @@ -153,10 +144,6 @@ export const Layer = (props: LayerProps) => { ) } - - - - ) }