-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from SpeciesFileGroup/development
Update schema and metadata
- Loading branch information
Showing
14 changed files
with
112 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { useHead } from 'unhead' | ||
|
|
||
| function provideResolver(input, resolver) { | ||
| if (!input) input = {} | ||
|
|
||
| input._resolver = resolver | ||
|
|
||
| return input | ||
| } | ||
|
|
||
| export function defineTaxon(input) { | ||
| return provideResolver(input, 'taxon') | ||
| } | ||
|
|
||
| export function useSchemaOrg(nodes) { | ||
| return useHead({ | ||
| script: [ | ||
| { | ||
| type: 'application/ld+json', | ||
| key: 'schema-org-graph', | ||
| nodes | ||
| } | ||
| ] | ||
| }) | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { loadResolver } from './loadResolver' | ||
|
|
||
| function transformToSchemaNode(node, { host }) { | ||
| const nodeResolver = loadResolver(node._resolver) | ||
|
|
||
| return nodeResolver(node, { host }) | ||
| } | ||
|
|
||
| export function schemaOrgPlugin({ host }) { | ||
| return { | ||
| hooks: { | ||
| 'tags:resolve': async function (ctx) { | ||
| for (const tag of ctx.tags) { | ||
| if (tag.tag === 'script' && tag.key === 'schema-org-graph') { | ||
| tag.innerHTML = JSON.stringify( | ||
| { | ||
| '@context': 'https://schema.org', | ||
| '@graph': tag.props.nodes.map((node) => { | ||
| return transformToSchemaNode(node, { host }) | ||
| }) | ||
| }, | ||
| null, | ||
| 2 | ||
| ) | ||
| delete tag.props.nodes | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { taxonResolver } from './nodes' | ||
|
|
||
| export function loadResolver(resolver) { | ||
| switch (resolver) { | ||
| case 'taxon': | ||
| return taxonResolver | ||
| default: | ||
| return () => ({}) | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './Taxon' |
This file was deleted.
Oops, something went wrong.