Skip to content

Instantly share code, notes, and snippets.

@Reedyn
Last active April 25, 2018 08:38
Show Gist options
  • Save Reedyn/5baad81436e08dcdc55c to your computer and use it in GitHub Desktop.
Save Reedyn/5baad81436e08dcdc55c to your computer and use it in GitHub Desktop.
JSON-LD implementation for Jönköping University Library
<script id="jul-jsonld">
var jsonld = {
"@context": "http://schema.org",
"@id": "http://ju.se/bibliotek",
"@type": "Library",
"name": "Högskolebiblioteket i Jönköping",
"alternateName": "Jönköping University Library",
"address": {
"streetAddress": "Gjuterigatan 5",
"addressLocality": "Jönköping",
"postalCode": "55318",
"addressCountry": "Sweden"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": "57.7793598",
"longitude": "14.1620846"
},
"telephone": "+46 36 10 10 10",
"email": "biblioteket@ju.se",
"openingHoursSpecification": {}
};
var script = $('<script>');
script.attr('type','application/ld+json');
// Grab Opening Hours from LibCal's API
$.ajax({
url: 'http://api3.libcal.com/api_hours_grid.php?format=jsonld&iid=3237&lid=1884&callback=jsonld',
jsonpCallback: "jsonld",
dataType: "jsonp"
}).then(function(data){
// Add Opening Hours from LibCal to our JSON-LD object
jsonld.openingHoursSpecification = data.openingHoursSpecification;
script.html(JSON.stringify(jsonld));
// Append the JSON-LD element to body
$('body').append(script);
});
</script>
@bjarman
Copy link

bjarman commented Apr 25, 2018

Hej!
Fungerar detta bra för ert bibliotek?
Dvs konsumerar google json-ld och visar öppettiderna korrekt?
/Fredrik -Uppsala Universitetsbibliotek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment