Skip to content

Map schema.org pending properties #62

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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