Replies: 1 comment
-
@abotzki ... this is actually possible, you can try this out here You can use a script-tag for this, for which <!--
@JSONLD
<script run-once>
let json = @0
const script = document.createElement('script');
script.type = 'application/ld+json';
script.text = JSON.stringify(json);
document.head.appendChild(script);
// this is only needed to prevent and output,
// as long as the result of a script is undefined,
// it is not shown or rendered within LiaScript
console.debug("added json to head")
</script>
@end
@onload
alert("TODO: insert your json here")
@end
-->
# Linked Data 🔗
An elegant solution for adding linked data dynamically might be the usage of one ore more custom macros.
Within the head of this document there is one custom macro called `@JSONLD`, which outputs a script-tag
with the parameter `run-once` and one parameter-substitution `@0`. In the example below a code-block is
defined with a macro-call in its head. This means that the entire body of the code-block is passed as the
zero or first parameter.
As an alternative, you can also add the JavaScript code into the `@onload` body. This is a special macro
that contains some code that is only loaded once, during load of the document...
```json @JSONLD
{
"@context": "https://schema.org/",
"@type": "LearningResource",
"@id": "https://elixir-europe-training.github.io/ELIXIR-TrP-TeSS/",
"http://purl.org/dc/terms/conformsTo": {
"@type": "CreativeWork",
"@id": "https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE"
},
"description": "TeSS, how can I help you? This is our interactive hands-on course about efficient use of the ELIXIR TeSS platform.",
"keywords": "FAIR, OPEN, Bioinformatics, Teaching, TeSS",
"name": "TeSS, how can I help you?",
"license": "https://creativecommons.org/licenses/by/4.0/",
"educationalLevel": "beginner",
"competencyRequired": "none",
"teaches": [
"search events and material in TeSS via direct and faceted search",
"add manually and automatically events and material to TeSS",
"extract events and material from TeSS by using TeSS widgets"
],
"audience": "training providers",
"inLanguage": "en-US",
"learningResourceType": [
"tutorial"
],
"author": [
{
"@type": "Person",
"name": "Bruna Piereck"
},
{
"@type": "Person",
"name": "Olivier Sand"
},
{
"@type": "Person",
"name": "Alexander Botzki"
}
],
"contributor": [
{
"@type": "Person",
"name": "Yasmine Maes"
},
{
"@type": "Person",
"name": "Finn Bacall"
},
{
"@type": "Person",
"name": "Munazah Andrabi"
}
]
}
``` Here is a screenshot of the example with the added JSON-LD part ... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @andre-dietrich,
related to this discussion #118, I was wondering whether the macro
script
could be also used to digest a JSON-LD object and inject it in the header of the rendered Liascript course.If it could be ingested via such a mechanism, the rendered course via https://liascript.github.io/?https://raw.... would contain the complete JSON-LD object.
Below, you'll find an example of a manually created entry.
Beta Was this translation helpful? Give feedback.
All reactions