Skip to content

Commit

Permalink
Add more fallback options for page time
Browse files Browse the repository at this point in the history
  • Loading branch information
dmstern committed Feb 2, 2021
1 parent d353f54 commit c94c597
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/bookmark-url.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions src/html2biblatex.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,22 @@
const today = new Date();
const urldate = jsDate2bibTex(today);

const lastModDate = new Date(document.lastModified);
const date = jsDate2bibTex(lastModDate);
const year = date2YearTex(lastModDate);
const publishedTime = document
.querySelector('meta[property="article:published_time"')
?.getAttribute("content");
const someTimeTag = document
.querySelector("time[datetime]")
?.getAttribute("datetime");
const lastModifiedTime = document.lastModified;

const pageTime = new Date(
publishedTime ||
someTimeTag ||
someTimeTagWithoutDatetime ||
lastModifiedTime
);
const date = jsDate2bibTex(pageTime);
const year = date2YearTex(pageTime);

// remove special characters for citation key:
let title_key = title.replace(/[^0-9a-z]/gi, "");
Expand Down

0 comments on commit c94c597

Please sign in to comment.