Replies: 1 comment 1 reply
-
I would see composition doing better in this kind of setup, tho I'm unsure which would fit better in Next's case, as I'm not that familiar with it anymore. Modified example: import Image from 'next/image';
import { Creator, LinkedData } from 'next/jsonld';
const MyComponent = () => (
<div>
<Image
src="https://example.com/photos/320/black-labrador-puppy-800w.jpg"
alt="Black labrador puppy"
width={800}
height={600}
>
<LinkedData
type="ImageObject", // Could probably be inferred from the context
contentUrl="https://example.com/photos/320/black-labrador-puppy-800w.jpg"
licenseUrl="https://example.com/license"
acquireLicenseUrl="https://example.com/how-to-use-my-images"
creditText="Labrador PhotoLab"
copyrightNotice="John Doe"
>
<Creator
type="Person"
name="Anakin Skywalker"
/>
</LinkedData>
</Image>
</div>
) Thoughts? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
Currently, the
next/image
component in Next.js is excellent for optimizing images in terms of performance and responsiveness.However, it lacks native support for embedding JSON+LD schema, which is crucial for enhancing SEO. JSON+LD (JavaScript Object Notation for Linked Data) allows webmasters to provide structured data for search engines, thereby improving the visibility of images in search results. While it is possible to manually add JSON+LD scripts in your code by using
dangerouslySetInnerHTML
, having native support within thenext/image
component would streamline this process and encourage best practices across Next.js projects !Proposal
The proposed feature involves adding an optional parameter to the
next/image
component that allows users to include a JSON+LD schema for images. This parameter would accept a JSON object with fields such ascontentUrl
,license
,acquireLicensePage
,creditText
,creator
, andcopyrightNotice
, that I took from the Google Documentation.The implementation would involve:
next/image
component to accept a new prop,jsonLd
.jsonLd
prop is provided, the component would automatically generate and insert the corresponding JSON+LD script into the HTML head.ImageObject
.Example code:
Alternative example suggested by @xtrm-en
Are you interested in contributing?
Yes, I am willing to contribute to the implementation of this feature and collaborate with the Next.js team to ensure its successful integration.
Additionally, this is my first time proposing a feature, so I am open to any alternatives or constructive feedback ! Please feel free to share your thoughts and suggestions.
Beta Was this translation helpful? Give feedback.
All reactions