Skip to content

Instantly share code, notes, and snippets.

@kjgarza
Last active July 25, 2023 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kjgarza/34ca6a866b4437bc1c07d84f208a01c4 to your computer and use it in GitHub Desktop.
Save kjgarza/34ca6a866b4437bc1c07d84f208a01c4 to your computer and use it in GitHub Desktop.
JavaScript script to enable Content-Negotiation call for DataCite metadata in schema.org format
$(document).ready(function() {
var identifier = "https://doi.org/10.5284/1015681"; //for example 10.5284/1015681
if (identifier === undefined) {
return;
}
var doi = new URL(identifier);
var url = "https://data.crosscite.org";
url += '/application/vnd.schemaorg.ld+json/' + doi.pathname;
$.ajax({
url: url,
dataType: 'text', // don't convert JSON to Javascript object
success: function(data) {
$('<script>')
.attr('type', 'application/ld+json')
.text(data)
.appendTo('head');
},
error: function (error) {
console.log(error.responseJSON);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment