Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Add support for schema metatags #7

Open
wants to merge 6 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

mtodor
Copy link

@mtodor mtodor commented Aug 29, 2018

Fixes #6

Here is proposal for exposing schema metatags. I split base metatags and schema metatags into two fields, because it's easier to manage that on frontend part too.

To query schema metatags, I just add field for entity:

schema_metatags: entitySchemaMetatags {
        key
        content
}

and after that map values to object like this:

<script type="application/ld+json">
  {JSON.stringify({
    '@context': 'https://schema.org',
    '@graph': [
      schema_metatags.reduce((res, entry) => {
        res[entry.key] = JSON.parse(entry.content);
        return res;
      }, {}),
    ],
  })}
</script>

And that's it.

Bad part is, that content is encoded json, but I would like to avoid too much nesting.

@codecov
Copy link

codecov bot commented Aug 29, 2018

Codecov Report

Merging #7 into 8.x-1.x will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@          Coverage Diff          @@
##           8.x-1.x    #7   +/-   ##
=====================================
  Coverage        0%    0%           
=====================================
  Files            7    13    +6     
  Lines           67   110   +43     
=====================================
- Misses          67   110   +43
Impacted Files Coverage Δ
src/Plugin/GraphQL/Types/SchemaMeta.php 0% <0%> (ø)
src/Plugin/GraphQL/Types/MetaValue.php 0% <0%> (ø) ⬆️
src/Plugin/GraphQL/Fields/Metatag/Content.php 0% <0%> (ø)
src/Plugin/GraphQL/Fields/Metatag/Key.php 0% <0%> (ø) ⬆️
...gin/GraphQL/Fields/Entity/EntitySchemaMetatags.php 0% <0%> (ø)
src/Plugin/GraphQL/Types/MetaItemProp.php 0% <0%> (ø)
...rc/Plugin/GraphQL/Fields/Entity/EntityMetatags.php 0% <0%> (ø) ⬆️
src/Plugin/GraphQL/Fields/InternalUrl/Metatags.php 0% <0%> (ø) ⬆️
src/Plugin/GraphQL/Types/MetaHttpEquiv.php 0% <0%> (ø)
...ugin/GraphQL/Fields/InternalUrl/SchemaMetatags.php 0% <0%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48140c3...c9eec6f. Read the comment docs.

@Luigisa
Copy link

Luigisa commented Nov 20, 2020

Hello,

i have joined as maintainer of this module and have already applied this fix in the official drupal repository.

https://www.drupal.org/project/graphql_metatag

Regards

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for JSON-LD MetaTags
3 participants