From 92837c73ba7161549fc1f1f0c4e632d94f154f86 Mon Sep 17 00:00:00 2001 From: Ammaar Aslam Date: Sat, 20 Aug 2022 12:24:17 +0530 Subject: [PATCH] dynamically change website pages (site pages) --- src/meta/DefMeta.jsx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/meta/DefMeta.jsx b/src/meta/DefMeta.jsx index 8717739a3..771a0f9a4 100644 --- a/src/meta/DefMeta.jsx +++ b/src/meta/DefMeta.jsx @@ -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 ( + {title} @@ -23,7 +44,7 @@ function DefMeta() { />