diff --git a/package.json b/package.json index 925bfcb..744329d 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,14 @@ "@semantic-ui-react/css-patch": "^1.1.1", "@types/leaflet": "^1.8.0", "@types/react": "^18.0.12", + "@types/react-helmet": "^6.1.5", "@types/styled-components": "^5.1.24", "dayjs": "^1.11.0", "leaflet": "^1.9.1", "pure-react-carousel": "^1.29.0", "react": "^18.2.0", "react-app-polyfill": "^3.0.0", + "react-helmet": "^6.1.0", "react-leaflet": "^3.1.0", "react-markdown": "^8.0.1", "react-refresh": "^0.14.0", diff --git a/src/components/DynamicMetaTags.tsx b/src/components/DynamicMetaTags.tsx new file mode 100644 index 0000000..41acc1b --- /dev/null +++ b/src/components/DynamicMetaTags.tsx @@ -0,0 +1,30 @@ +import { FC } from 'react' +import { Helmet } from 'react-helmet' +import { Ticker } from '../lib/types' + +interface Props { + ticker: Ticker +} + +const DynamicMetaTags: FC = ({ ticker }) => { + return ( + + + + + + + + + + + + ) +} + +export default DynamicMetaTags diff --git a/src/views/ActiveView.tsx b/src/views/ActiveView.tsx index 53a31f5..40f4876 100644 --- a/src/views/ActiveView.tsx +++ b/src/views/ActiveView.tsx @@ -7,6 +7,7 @@ import { isMobile } from '../lib/helper' import About from '../components/About' import ReloadInfo from '../components/ReloadInfo' import MessageList from '../components/MessageList' +import DynamicMetaTags from '../components/DynamicMetaTags' const Wrapper = styled(Container)` padding: ${spacing.normal} 0; @@ -23,13 +24,11 @@ interface Props { type StickyContext = Document | Window | HTMLElement | React.Ref -const ActiveView: FC = props => { +const ActiveView: FC = ({ ticker, refreshInterval }) => { const [stickyContext, setStickyContext] = useState() const headline = - props.ticker === null || props.ticker.title == undefined - ? 'Ticker' - : props.ticker.title + ticker === null || ticker.title == undefined ? 'Ticker' : ticker.title const handleContextRef = useCallback((stickyContextValue: StickyContext) => { setStickyContext(stickyContextValue) @@ -38,28 +37,30 @@ const ActiveView: FC = props => { if (isMobile()) { return ( - + + {headline && } - + ) } return ( + {headline && }
- +
- +
diff --git a/yarn.lock b/yarn.lock index a6c2b32..19c812b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2080,6 +2080,13 @@ dependencies: "@types/react" "*" +"@types/react-helmet@^6.1.5": + version "6.1.5" + resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-6.1.5.tgz#35f89a6b1646ee2bc342a33a9a6c8777933f9083" + integrity sha512-/ICuy7OHZxR0YCAZLNg9r7I9aijWUWvxaPR6uTuyxe8tAj5RL4Sw1+R6NhXUtOsarkGYPmaHdBDvuXh2DIN/uA== + dependencies: + "@types/react" "*" + "@types/react@*", "@types/react@^18.0.12": version "18.0.12" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.12.tgz#cdaa209d0a542b3fcf69cf31a03976ec4cdd8840" @@ -7465,11 +7472,21 @@ react-error-overlay@^6.0.11: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb" integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg== -react-fast-compare@^3.0.1: +react-fast-compare@^3.0.1, react-fast-compare@^3.1.1: version "3.2.0" resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb" integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA== +react-helmet@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726" + 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" + react-is@^16.13.1, react-is@^16.6.3, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" @@ -7526,6 +7543,11 @@ react-refresh@^0.14.0: resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e" integrity sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ== +react-side-effect@^2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.2.tgz#dc6345b9e8f9906dc2eeb68700b615e0b4fe752a" + integrity sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw== + react@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"