Added LD+JSON asset and test case#1936
Conversation
| this.registerExtension('vue', './assets/VueAsset'); | ||
| this.registerExtension('json', './assets/JSONAsset'); | ||
| this.registerExtension('json5', './assets/JSONAsset'); | ||
| this.registerExtension('json-ld', './assets/JSONLDAsset'); |
There was a problem hiding this comment.
let's make the extension .jsonld as specified here: https://json-ld.org/spec/latest/json-ld/#iana-considerations
| "logo", | ||
| "photo", | ||
| "image" | ||
| ]; |
There was a problem hiding this comment.
Good start. I guess we should go through the specs and find all the possible attributes that are URLs
There was a problem hiding this comment.
Not sure if they list every single property, but https://schema.org/ImageObject has a dependents list: "Instances of ImageObject may appear as values for the following properties"
|
@devongovett , can I add a new cli parameter ? I can't really see another way to (properly) solve the issue with URLs/paths. Or reuse |
| (rendition.type === 'js' && node.tag === 'script') || | ||
| (rendition.type === 'css' && node.tag === 'style') | ||
| (rendition.type === 'css' && node.tag === 'style') || | ||
| (rendition.type === 'jsonld' && node.tag === 'script') |
There was a problem hiding this comment.
Why not just check isAstDirty ?
| collectDependencies() { | ||
| for (let schemaKey in this.ast) { | ||
| // only check for single values, not nested data | ||
| // todo: check for nested data |
There was a problem hiding this comment.
make a recursive function for this?
| this.ast[schemaKey] = assetPath; | ||
| this.isAstDirty = true; | ||
|
|
||
| if (this.options.publicURL === '/') { |
There was a problem hiding this comment.
so I take it JSON LD requires full URLs not paths? If so, then this is probably fine to show a warning.
Maybe this check should check whether the public URL starts with / instead of fully equaling it?
| this.isAstDirty = true; | ||
|
|
||
| if (this.options.publicURL === '/') { | ||
| console.warn( |
There was a problem hiding this comment.
use the parcel logger for this
| 'image', | ||
| 'thumbnail', | ||
| 'screenshot', | ||
| 'primaryImageOfPage' |
There was a problem hiding this comment.
You could look through https://schema.org/URL for more URL instances. Maybe Video/MediaObject and a few others of those would be good to support too.
|
I still think |
| // Delete "type" attribute, since CSS and JS are the defaults. | ||
| if (node.attrs) { | ||
| // Unless it's application/ld+json | ||
| if (node.attrs && node.attrs.type !== 'application/ld+json') { |
|
@devongovett needs a final review |
Closes #1935
📋 TODO
Review ✨
👌 DONE
public-urlparameter. Avoids creating a new flag but spams the DOMmsapplication-config. Complements Add support for HTML meta assets #747type="application/ld+json"Minify JSON (Handled by htmlnanotransform)JSON.stringify()💁 Possible Solution for URLs
Ask for URL using a new parameter (
published-url?)Assume the user will enter a full URL (warn otherwise) in the schema
Use
public-url