Skip to content

Commit

Permalink
Revert "Helmet implementation"
Browse files Browse the repository at this point in the history
This reverts commit 4ae59a8.
  • Loading branch information
martinheppner committed Sep 1, 2024
1 parent 248cbd8 commit 38d5dff
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 224 deletions.
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"redux-thunk": "^2.4.1",
"uuid": "^9.0.0",
"watch": "^0.13.0",
"web-vitals": "^3.3.0",
"webpack-cli": "^5.1.4"
},
"overrides": {
Expand Down
28 changes: 26 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
<!DOCTYPE html>
<html id="html-tag">
<html lang="de" id="html-tag">
<head>
<link rel="alternate" href="https://www.zuugle.si" hreflang="sl-si" />
<link rel="canonical" href="https://www.zuugle.at" hreflang="de-at" />
<link rel="alternate" href="https://www.zuugle.de" hreflang="de-de" />
<link rel="alternate" href="https://www.zuugle.it" hreflang="it-it" />
<link rel="alternate" href="https://www.zuugle.ch" hreflang="de-ch" />
<link rel="alternate" href="https://www.zuugle.li" hreflang="de-li" />
<link rel="alternate" href="https://www.zuugle.fr" hreflang="fr-fr" />
<link rel="preconnect" href="https://www.bahn-zum-berg.at" />

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />

<meta name="author" content="Zuugle"/>
<meta name="publisher" content="Bahn zum Berg"/>
<meta name="copyright" content="Bahn zum Berg"/>
<meta http-equiv="content-language" content="de"/>
<meta name="robots" content="index, follow"/>

<!-- Primary Meta Tags -> now using react helmet -->

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.zuugle.at/">
<meta property="og:title" content="Zuugle - die Suchmaschine für Öffi-Bergtouren im österreichischen Alpenraum">
<meta
property="og:description"
content="Zuugle zeigt dir geprüfte Verbindungen mit Bahn und Bus zu Bergtouren, Wanderungen, Skitouren, Schneeschuhwanderungen, etc. von deinem Wohnort aus an.">
<meta property="og:image" content="https://www.zuugle.at/app_static/img/Zuugle_Opengraph.jpg">

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://www.zuugle.at/">
<meta property="twitter:title" content="Zuugle - die Suchmaschine für Öffi-Bergtouren im österreichischen Alpenraum">

<!-- Primary Meta Tags -> now using react helmet -->
<meta
property="twitter:description"
content="Zuugle zeigt dir geprüfte Verbindungen mit Bahn und Bus zu Bergtouren, Wanderungen, Skitouren, Schneeschuhwanderungen, etc. von deinem Wohnort aus an.">
<meta property="twitter:image" content="https://www.zuugle.at/app_static/img/Zuugle_Opengraph.jpg">
</head>

<body>
Expand Down
6 changes: 3 additions & 3 deletions src/components/LanguageMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import CloseIcon from "@mui/icons-material/Close";
import { langChange } from "../../utils/language_Utils";
import { Modal } from "@mui/material";
import { useTranslation } from "react-i18next";
import { get_currLanguage } from "../../utils/globals"


function LanguageMenu({pageKey}) {
const { i18n } = useTranslation();

let currLanguage = get_currLanguage();

var resolvedLanguage = i18n.language
const storedLanguage = localStorage.getItem("lang");
let currLanguage = storedLanguage || resolvedLanguage;
const [Languages, setLanguages] = useState([
{ key: "en", nativeName: "English" },
{ key: "fr", nativeName: "Français" },
Expand Down
5 changes: 5 additions & 0 deletions src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
121 changes: 4 additions & 117 deletions src/utils/globals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from "moment";
import useMediaQuery from "@mui/material/useMediaQuery";
import { useTranslation } from "react-i18next";


export function convertNumToTime(number, nonseparate = false) {
Expand Down Expand Up @@ -27,14 +27,6 @@ export function convertNumToTime(number, nonseparate = false) {
return (!nonseparate) ? `${hour} h ${minute} min` : `${hour}:${minute} h`;
}

export const get_currLanguage = () => {
const { i18n } = useTranslation();
var resolvedLanguage = i18n.language
const storedLanguage = localStorage.getItem("lang");
const currLanguage = storedLanguage || resolvedLanguage;
return currLanguage;
}

export const simpleConvertNumToTime = (number)=> {
let timeStr = convertNumToTime(number);
timeStr = timeStr.replace(/ h/g, '').replace(/ min/g, '');
Expand Down Expand Up @@ -103,96 +95,6 @@ export const getDomainText = () => {
}
}


export const get_meta_data = (page) => {
const { t } = useTranslation();

let meta = [];
const _domaintext = getDomainText();
const host = window.location.hostname;

meta.currLang = '<meta http-equiv="content-language" content="'+get_currLanguage()+'" />';

if (page === 'Start') {
if (_domaintext === "Zuugle.fr") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.fr" hreflang="fr-fr" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.si") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.si" hreflang="sl-si" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.de") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.de" hreflang="de-de" />'
meta.preconnect_bzb = '<link rel="preconnect" href="https://www.bahn-zum-berg.at" /> '
} else if (_domaintext === "Zuugle.it") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.it" hreflang="it-it" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.ch") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.ch" hreflang="de-ch" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.li") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.li" hreflang="de-li" />'
meta.preconnect_bzb = '';
} else {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.at" hreflang="de-at" />';
meta.preconnect_bzb = '<link rel="preconnect" href="https://www.bahn-zum-berg.at" /> ';
}
meta.opengraph = '<meta property="og:url" content="'+host+'"><meta property="og:title" content="'+t("start.helmet_title")+'"><meta property="og:description" content="'+t("index.zuugle_description")+'"><meta property="og:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
meta.twitter = '<meta property="twitter:url" content="'+host+'"><meta property="twitter:title" content="'+t("start.helmet_title")+'"><meta property="twitter:description" content="'+t("index.zuugle_description")+'"><meta property="twitter:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
} else if (page === 'Impressum') {
meta.preconnect_bzb = '';
meta.canonical = '<link rel="alternate" href="https://www.zuugle.fr/imprint" hreflang="fr-fr" />'
+ '<link rel="alternate" href="https://www.zuugle.si/imprint" hreflang="sl-si" />'
+ '<link rel="alternate" href="https://www.zuugle.de/imprint" hreflang="de-de" />'
+ '<link rel="alternate" href="https://www.zuugle.it/imprint" hreflang="it-it" />'
+ '<link rel="alternate" href="https://www.zuugle.ch/imprint" hreflang="de-ch" />'
+ '<link rel="alternate" href="https://www.zuugle.li/imprint" hreflang="de-li" />'
+ '<link rel="canonical" href="https://www.zuugle.at/imprint" hreflang="de-at" />';
meta.opengraph = '<meta property="og:url" content="'+host+'"><meta property="og:title" content="Impressum - '+t("start.helmet_title")+'"><meta property="og:description" content="'+t("index.zuugle_description")+'"><meta property="og:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
meta.twitter = '<meta property="twitter:url" content="'+host+'"><meta property="twitter:title" content="Impressum - '+t("start.helmet_title")+'"><meta property="twitter:description" content="'+t("index.zuugle_description")+'"><meta property="twitter:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
} else if (page === 'Privacy') {
meta.preconnect_bzb = '';
meta.canonical = '<link rel="alternate" href="https://www.zuugle.fr/privacy" hreflang="fr-fr" />'
+ '<link rel="alternate" href="https://www.zuugle.si/privacy" hreflang="sl-si" />'
+ '<link rel="alternate" href="https://www.zuugle.de/privacy" hreflang="de-de" />'
+ '<link rel="alternate" href="https://www.zuugle.it/privacy" hreflang="it-it" />'
+ '<link rel="alternate" href="https://www.zuugle.ch/privacy" hreflang="de-ch" />'
+ '<link rel="alternate" href="https://www.zuugle.li/privacy" hreflang="de-li" />'
+ '<link rel="canonical" href="https://www.zuugle.at/privacy" hreflang="de-at" />';
meta.opengraph = '<meta property="og:url" content="'+host+'"><meta property="og:title" content="Privacy - '+t("start.helmet_title")+'"><meta property="og:description" content="'+t("index.zuugle_description")+'"><meta property="og:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
meta.twitter = '<meta property="twitter:url" content="'+host+'"><meta property="twitter:title" content="Privacy - '+t("start.helmet_title")+'"><meta property="twitter:description" content="'+t("index.zuugle_description")+'"><meta property="twitter:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
} else if (page === 'Main') {
if (_domaintext === "Zuugle.fr") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.fr/search" hreflang="fr-fr" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.si") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.si/search" hreflang="sl-si" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.de") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.de/search" hreflang="de-de" />'
meta.preconnect_bzb = '<link rel="preconnect" href="https://www.bahn-zum-berg.at" /> '
} else if (_domaintext === "Zuugle.it") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.it/search" hreflang="it-it" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.ch") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.ch/search" hreflang="de-ch" />'
meta.preconnect_bzb = '';
} else if (_domaintext === "Zuugle.li") {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.li/search" hreflang="de-li" />'
meta.preconnect_bzb = '';
} else {
meta.canonical = '<link rel="canonical" href="https://www.zuugle.at/search" hreflang="de-at" />';
meta.preconnect_bzb = '<link rel="preconnect" href="https://www.bahn-zum-berg.at" /> ';
}

meta.opengraph = '<meta property="og:url" content="'+host+'"><meta property="og:title" content="Search - '+t("start.helmet_title")+'"><meta property="og:description" content="'+t("index.zuugle_description")+'"><meta property="og:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
meta.twitter = '<meta property="twitter:url" content="'+host+'"><meta property="twitter:title" content="Search - '+t("start.helmet_title")+'"><meta property="twitter:description" content="'+t("index.zuugle_description")+'"><meta property="twitter:image" content="'+host+'/app_static/img/Zuugle_Opengraph.jpg">';
}

console.log("meta: ", meta.currLang+meta.canonical+meta.preconnect_bzb+meta.opengraph+meta.twitter)
return meta.currLang+meta.canonical+meta.preconnect_bzb+meta.opengraph+meta.twitter;
}


export const useResponsive = () => {
const matches = useMediaQuery('(max-width:600px)');
return !!matches;
Expand All @@ -206,24 +108,9 @@ export function parseIfNeccessary(value) {
};

export const getTopLevelDomain = () => {
let domain = window.location.hostname;
let tld = "at";

if (domain.indexOf("zuugle.de") > 0) {
tld = "de";
} else if (domain.indexOf("zuugle.si") > 0) {
tld = "si";
} else if (domain.indexOf("zuugle.it") > 0) {
tld = "it";
} else if (domain.indexOf("zuugle.ch") > 0) {
tld = "ch";
} else if (domain.indexOf("zuugle.li") > 0) {
tld = "li";
} else if (domain.indexOf("zuugle.fr") > 0) {
tld = "fr";
}

return tld;
let host = window.location.hostname;
host = host.replaceAll('www2.', '').replaceAll('www.', '');
return host.substring(host.length-2).toLowerCase();
}


Expand Down
23 changes: 3 additions & 20 deletions src/views/Main/DetailReworked.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ import {
import ArrowBefore from "../../icons/ArrowBefore";
import ShareIcon from "../../icons/ShareIcon";
import Close from "../../icons/Close";
import { shortenText, parseFileName, get_meta_data, get_currLanguage } from "../../utils/globals";
import { shortenText, parseFileName } from "../../utils/globals";
import transformToDescriptionDetail from "../../utils/transformJson";
import { Helmet } from "react-helmet";
import '/src/config.js';


Expand Down Expand Up @@ -274,6 +273,7 @@ useEffect(() => {
setGpxTrack(tour.totour_gpx_file, loadGPX, setAnreiseGpxPositions);
setGpxTrack(tour.fromtour_gpx_file, loadGPX, setAbreiseGpxPositions);
setRenderImage(!!tour?.image_url);
// }
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tour]);
Expand Down Expand Up @@ -538,30 +538,13 @@ useEffect(() => {
</Box>
);

const currLanguage = get_currLanguage();
let page_title = 'Zuugle';
if (!!tour) {
page_title = tour.title+' - '+tour.provider_name;
}

return (

<Box sx={{ backgroundColor: "#fff" }}>
{isTourLoading ? (
<LoadingSpinner />
) : (
<>
<Helmet>
<title>{page_title}</title>
<meta http-equiv="content-language" content="{currLanguage}" />
<meta property="og:url" content="'+host+'" />
<meta property="og:title" content="{page_title}" />
<meta property="og:description" content="" />
<meta property="og:image" content="{(tour?.image_url && tour?.image_url.length > 0) && tour?.image_url}" />
<meta property="twitter:url" content="'+host+'" />
<meta property="twitter:title" content="{page_title}" />
<meta property="twitter:description" content="" />
<meta property="twitter:image" content="{(tour?.image_url && tour?.image_url.length > 0) && tour?.image_url}" />
</Helmet>
<Box className="newHeader" sx={{ position: "relative" }}>
<Box component={"div"} className="rowing blueDiv">
{/* close tab /modal in case no return history available ###### section */}
Expand Down
Loading

0 comments on commit 38d5dff

Please sign in to comment.