Allow customizing the way JSON-LD data is injected into pages#822
Allow customizing the way JSON-LD data is injected into pages#822oscarotero merged 1 commit intolumeland:mainfrom
Conversation
5a169c7 to
1df5bfc
Compare
|
Why do you want to customize this? |
|
I prefer putting the data at the end of I also think having the ability to inject the data into the page via Javascript is a nice addition. That's why I pass |
|
For the failing test, I don't know why my update affects the 2nd file's output. |
|
I see. site.use(jsonLd({
placement: "head" // The default option. Available options: "head" and "body"
}); |
|
What do you think about adding a 3rd option It's a bit weird for a user to write |
|
Ok, but in this case, I'd make this option a boolean:
This allows anyone to place it in a different position, or customize the object a bit more with a processor. In this case, a better option name could be site.use(jsonLd({
insert: false
}));
site.process([".html"], (pages) => {
for (const page of pages) {
const { jsonLd } = page.data;
const jsonLdContent = JSON.stringify(jsonLd);
}
}); |
1df5bfc to
20499aa
Compare
20499aa to
a48a5dd
Compare
|
I updated the PR with your suggestion. This is unrelated, but too minor to be worth a GitHub issue: can you update |
|
Perfect, thanks!
Sure, I have the |
Description
The JSON-LD data can be placed inside a
<script>tag anywhere on a HTML page. Google supports it either:<head>or<body>elementsRef: https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data#supported-formats
Related Issues
Check List
CODE OF CONDUCT
CONTRIBUTING
send multiple pull request.
fmtto fix the code format before commit.CHANGELOG.md.