This commit is contained in:
jake committed 2021-09-30 08:28:19 -04:00
1 parent 2b918ea027
commit e588f7674c
3 files changed
+61 -40

No files matched your search

+9 -1
View File
@@ -1,12 +1,20 @@
import fetch from "cross-fetch";
import urlParse from "url-parse";
import numeral from "numeral";
import canonicalUrl from "get-canonical-url";
// don't continue if there isn't a span#meta-hits element on this page
const wrapper = document.getElementById("meta-hits");
// use <link rel="canonical"> to deduce a consistent identifier for this page
const canonical = document.head.querySelector("link[rel='canonical']");
const canonical = canonicalUrl({
normalize: true,
normalizeOptions: {
removeTrailingSlash: true,
removeQueryParameters: true,
stripHash: true,
},
});
// page must have both span#meta-hits and canonical URL to enter
if (wrapper && canonical) {