parent
4161c5587c
commit
7903f42776
|
|
@ -1,5 +1,15 @@
|
||||||
const getTitle = () => {
|
const getTitle = () => {
|
||||||
const title = document.title;
|
const title = document.title;
|
||||||
|
const metaTitle = document.querySelector<HTMLMetaElement>(`meta[name="title"]`);
|
||||||
|
const metaOgTitle = document.querySelector<HTMLMetaElement>(`meta[name="og:title"]`);
|
||||||
|
|
||||||
|
if (metaOgTitle) {
|
||||||
|
return metaOgTitle.getAttribute("content");;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metaTitle) {
|
||||||
|
return metaTitle.getAttribute("content");;
|
||||||
|
}
|
||||||
|
|
||||||
if (title.includes(" - ")) {
|
if (title.includes(" - ")) {
|
||||||
const end = title.lastIndexOf(" - ");
|
const end = title.lastIndexOf(" - ");
|
||||||
|
|
@ -47,7 +57,7 @@ const getFrom = () => {
|
||||||
const getAuthor = () => {
|
const getAuthor = () => {
|
||||||
const metaAuthor = document.querySelector<HTMLMetaElement>(`meta[name="author"]`);
|
const metaAuthor = document.querySelector<HTMLMetaElement>(`meta[name="author"]`);
|
||||||
const metaOgAuthor = document.querySelector<HTMLMetaElement>(`meta[property="og:article:author"]`);
|
const metaOgAuthor = document.querySelector<HTMLMetaElement>(`meta[property="og:article:author"]`);
|
||||||
const itemPropAuthor = document.querySelector<HTMLMetaElement>(`[itemprop="author"] meta[itemprop="name"]`);
|
const itemPropAuthor = document.querySelector<HTMLMetaElement>(`[itemprop="author"] [itemprop="name"]`);
|
||||||
|
|
||||||
if (metaAuthor) {
|
if (metaAuthor) {
|
||||||
return metaAuthor.getAttribute("content");
|
return metaAuthor.getAttribute("content");
|
||||||
|
|
@ -98,8 +108,13 @@ const getSiteName = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTags = () => {
|
const getTags = () => {
|
||||||
|
const metaKeywords = document.querySelector<HTMLMetaElement>(`meta[name="keywords"]`);
|
||||||
const itemPropKeywords = document.querySelector<HTMLMetaElement>(`meta[itemprop="keywords"]`);
|
const itemPropKeywords = document.querySelector<HTMLMetaElement>(`meta[itemprop="keywords"]`);
|
||||||
|
|
||||||
|
if (metaKeywords) {
|
||||||
|
return metaKeywords.getAttribute("content");
|
||||||
|
}
|
||||||
|
|
||||||
if (itemPropKeywords) {
|
if (itemPropKeywords) {
|
||||||
return itemPropKeywords.getAttribute("content");
|
return itemPropKeywords.getAttribute("content");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue