1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-01-15 08:02:56 -05:00
This commit is contained in:
2021-09-30 08:28:19 -04:00
parent 2b918ea027
commit e588f7674c
3 changed files with 61 additions and 40 deletions

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) {