File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -96,11 +96,28 @@ for (const asset of assets) {
96
96
} ,
97
97
} ) . getBody ( ) ) ;
98
98
99
+
100
+ const schemaOrgDataModel = ( ( ) => {
101
+ // Note even though schema.org has migrated http://pending.schema.org/ to https://schema.org/
102
+ // We still use https://pending.schema.org/ to simplify the tooling (as the modelling specification does not
103
+ // allow for arbitrary pending terms to be used as-is, they must instead be added to a custom extension)
104
+ const getPrefixReplacedId = ( entity ) => {
105
+ if ( entity [ 'https://schema.org/isPartOf' ]
106
+ && entity [ 'https://schema.org/isPartOf' ] [ '@id' ] !== 'https://meta.schema.org' ) {
107
+ return entity [ '@id' ] . replace ( / ^ h t t p s : \/ \/ s c h e m a .o r g / , entity [ 'https://schema.org/isPartOf' ] [ '@id' ] ) ;
108
+ }
109
+ return entity [ '@id' ] ;
110
+ } ;
111
+
112
+ return schema [ '@graph' ] . map ( entity => getPrefixReplacedId ( entity ) ) ;
113
+ } ) ( ) ;
114
+
115
+
99
116
fs . writeFileSync (
100
117
path . join ( distPath , `${ asset . name } .js` ) ,
101
118
`/* eslint-disable */
102
119
// This is a generated file. Do not edit manually.
103
- module.exports = ${ JSON . stringify ( schema ) } ;` ,
120
+ module.exports = ${ JSON . stringify ( { schema, ... { '@graph' : schemaOrgDataModel } } ) } ;` ,
104
121
( ) => { } ,
105
122
) ;
106
123
}
You can’t perform that action at this time.
0 commit comments