-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON-LD plugin #453
Comments
Hi, can I do this? I think the best way is to modify the metas plugin, what do you think? |
Hey @shuaixr I don't think we should include this in the metas plugin, because JSON-LD is too big and complex. JSON-LD is hard, so I'd like a plugin that help to create entities easily. Maybe using a library like https://www.npmjs.com/package/schema-dts could be nice because it provides types to autocomplete the values. But would like to investigate if we can do it even easier. Let's see this example: {
'@type': 'Person',
'@id': 'https://my.site/#alyssa',
name: 'Alyssa P. Hacker',
hasOccupation: {
'@type': 'Occupation',
name: 'LISP Hacker',
qualifications: 'Knows LISP',
},
mainEntityOfPage: {'@id': 'https://my.site/about/#page'},
subjectOf: {'@id': 'https://my.site/about/#page'},
}, It should handle the URLs of the pages. The URLs {
'@type': 'Person',
'@id': '#alyssa',
name: 'Alyssa P. Hacker',
hasOccupation: {
'@type': 'Occupation',
name: 'LISP Hacker',
qualifications: 'Knows LISP',
},
mainEntityOfPage: {'@id': '/about/#page'},
subjectOf: {'@id': '/about/#page'},
}, It must allow aliases, in the same way as metas. For example: {
'@type': 'Person',
'@id': '#alyssa',
name: '=user.name',
hasOccupation: {
'@type': 'Occupation',
name: '=user.occupation.name',
qualifications: '=user.occupation.qualifications',
},
mainEntityOfPage: {'@id': '/about/#page'},
subjectOf: {'@id': '/about/#page'},
}, It should be able to show or hide entities if some values are empty. For example, if the user doesn't have occupation, instead of output the properties with empty values: {
'@type': 'Person',
'@id': 'https://my.site/#alyssa',
name: 'Alyssa P. Hacker',
hasOccupation: {
'@type': 'Occupation',
name: '',
qualifications: '',
},
mainEntityOfPage: {'@id': 'https://my.site/about/#page'},
subjectOf: {'@id': 'https://my.site/about/#page'},
}, It should omit this object: {
'@type': 'Person',
'@id': 'https://my.site/#alyssa',
name: 'Alyssa P. Hacker',
mainEntityOfPage: {'@id': 'https://my.site/about/#page'},
subjectOf: {'@id': 'https://my.site/about/#page'},
}, It would be nice if the plugin checked the data structure, in order to detect missing properties, or not found relations between entities. What do you think? I know it's complex, so we can start with the basics and improve it little by little. |
After closer look at the metas plugin, I think you're right. I'll open a draft pr soon |
Enter your suggestions in details:
More info: https://jsonld.com/
It could use: https://www.npmjs.com/package/schema-dts
Inspo: https://github.com/codiume/orbit/tree/main/packages/astro-seo-schema
The text was updated successfully, but these errors were encountered: