Skip to content

Commit

Permalink
dynamically change website pages (site pages)
Browse files Browse the repository at this point in the history
  • Loading branch information
ammaaraslam committed Aug 20, 2022
1 parent 3efb9bc commit 92837c7
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/meta/DefMeta.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import { Helmet } from "react-helmet";
import { useState, useEffect } from "react";
import { useLocation } from "react-router-dom";

function DefMeta() {
const [title, setTitle] = useState("ReactPlay - One app to learn, create, and share ReactJS projects.")
const currentPath = useLocation().pathname

useEffect(() => {
if (currentPath === "/plays") {
setTitle("ReactPlay - Plays")
}
if (currentPath === "/ideas") {
setTitle("ReactPlay - Ideas")
}
if (currentPath === "/tech-stacks") {
setTitle("ReactPlay - Tech Stacks")
}
else {
setTitle("ReactPlay - One app to learn, create, and share ReactJS projects.")
}

}, [currentPath])
return (
<Helmet>
<title>{title}</title>
<meta property="og:type" content="website" />
<meta property="og:site_name" content="ReactPlay" />
<meta property="og:image:type" content="image/png" />
Expand All @@ -23,7 +44,7 @@ function DefMeta() {
/>
<meta
property="og:title"
content="ReactPlay - One app to learn, create, and share ReactJS projects."
content={title}
data-react-helmet="true"
/>
<meta
Expand All @@ -43,7 +64,7 @@ function DefMeta() {
/>
<meta
name="twitter:title"
content="ReactPlay - One app to learn, create, and share ReactJS projects."
content={title}
data-react-helmet="true"
/>
<meta
Expand Down

0 comments on commit 92837c7

Please sign in to comment.