-
-
Save charlesvardeman/61dac8b743b73c22116c69ff52174020 to your computer and use it in GitHub Desktop.
JavaScript script to enable Content-Negotiation call for DataCite metadata in schema.org format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| var identifier = $("meta[name='DC.identifier']").attr("content"); | |
| if (identifier === undefined) { | |
| return; | |
| } | |
| var doi = new URL(identifier); | |
| var url = $('#site-title').attr('data-conneg'); | |
| 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