Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,28 @@ for (const asset of assets) {
},
}).getBody());

const schemaOrgDataModel = (() => {
// Note even though schema.org has migrated http://pending.schema.org/ to https://schema.org/
// We still use https://pending.schema.org/ to simplify the tooling (as the modelling specification does not
// allow for arbitrary pending terms to be used as-is, they must instead be added to a custom extension)
const getPrefixReplaced = (entity) => {
if (entity['schema:isPartOf']
&& entity['schema:isPartOf']['@id'] === 'https://pending.schema.org') {

entity['@id'] = entity['@id'].replace(/^schema:/, 'pending:');
return entity;
}
return entity;
};

return schema['@graph'].map(entity => getPrefixReplaced(entity));
})();

fs.writeFileSync(
path.join(distPath, `${asset.name}.js`),
`/* eslint-disable */
// This is a generated file. Do not edit manually.
module.exports = ${JSON.stringify(schema)};`,
module.exports = ${JSON.stringify({ schema, ...{ '@graph': schemaOrgDataModel } })};`,
() => {},
);
}
Expand Down