is it possible to make json with amp custom script? I have tried various ways and searched for answers on google, but always fail. is it possible?
<script id="json" type="text/plain" target="amp-script">
$(document).ready(function(){
var postId = '7686767';
var name = 'Test';
var url = 'example.com';
var datePublished = '2019-09-09';
var image = $('#image').attr('href');
var author_name = document.getElementById("author_name").textContent;
var description = document.getElementById("description").textContent;
var el = document.createElement('script');
el.type = 'application/ld+json';
el.text = JSON.stringify({
"@context": "https://schema.org/",
"@type": "Recipe",
"@id": postId,
"name": name,
"image": [
image
],
"author": {
"@type": "Person",
"name": author_name
},
"datePublished": datePublished,
"description": description,
});
document.querySelector('head').appendChild(el);
});
</script>
question from:
https://stackoverflow.com/questions/65886204/create-json-ld-with-amp-custom-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…