Skip to content

Commit e2f1985

Browse files
committed
added seo to readArticle
1 parent 550a728 commit e2f1985

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/data/articles.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ function article_1() {
66
title: "The Benefits of Cloud Computing",
77
description:
88
"Cloud computing offers a range of benefits, including cost savings and increased flexibility. Find out why more businesses are turning to the cloud.",
9+
keywords: [
10+
"The Benefits of Cloud Computing",
11+
"Tharindu",
12+
"Tharindu N",
13+
"Tharindu Nayanajith",
14+
],
915
style: `
1016
.article-content {
1117
display: flex;
@@ -40,6 +46,12 @@ function article_2() {
4046
description:
4147
"AI is transforming the healthcare industry, from improving patient outcomes to streamlining operations. Discover the latest applications of this game-changing technology.",
4248
style: ``,
49+
keywords: [
50+
"Artificial Intelligence in Healthcare",
51+
"Tharindu",
52+
"Tharindu N",
53+
"Tharindu Nayanajith",
54+
],
4355
body: (
4456
<React.Fragment>
4557
<h1>Content of article 2</h1>

src/pages/readArticle.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useEffect } from "react";
22
import { useNavigate, useParams } from "react-router-dom";
3+
import { Helmet } from "react-helmet";
34
import styled from "styled-components";
45

56
import NavBar from "../components/common/navBar";
@@ -20,7 +21,6 @@ const ReadArticle = () => {
2021
const article = myArticles[slug - 1];
2122

2223
useEffect(() => {
23-
document.title = `${article().title} | ${INFO.main.title}`;
2424
window.scrollTo(0, 0);
2525
}, [article]);
2626

@@ -30,6 +30,12 @@ const ReadArticle = () => {
3030

3131
return (
3232
<React.Fragment>
33+
<Helmet>
34+
<title>{`${article().title} | ${INFO.main.title}`}</title>
35+
<meta name="description" content={article().description} />
36+
<meta name="keywords" content={article().keywords.join(", ")} />
37+
</Helmet>
38+
3339
<div className="page-content">
3440
<NavBar />
3541

0 commit comments

Comments
 (0)