-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathscript.js
27 lines (22 loc) · 984 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const adjustCanonicalLink =()=> {
document.querySelector('link[rel="canonical"]').href = document.URL
}
const getSeoData = () => {
const pageTitle = document.title
const pageUrl = document.URL
const pageDescription = document.querySelector('meta[name="description"]').content
const pageImg = document.querySelectorAll('img')[0].src
setOgSeoData({ pageTitle, pageUrl, pageDescription, pageImg })
}
const setOgSeoData = ({ pageTitle, pageUrl, pageDescription, pageImg }) => {
document.querySelector('meta[property="og:url"]').content = pageUrl
document.querySelector('meta[property="og:title"]').content = pageTitle
document.querySelector('meta[property="og:site_name"]').content = pageTitle
document.querySelector('meta[property="og:description"]').content = pageDescription
document.querySelector('meta[property="og:image"]').content = pageImg
}
getSeoData()
adjustCanonicalLink()
/*
* Add here any JavaScript you want to use
*/