Skip to content

Commit

Permalink
fix: render JSON-LD correctly (#70)
Browse files Browse the repository at this point in the history
* fix typo

* fix typescript error

* add schema-dts to dependencies

The typescript auto complete for the json ld doesn't work if schema-dts is used as a devdependency. This commit fixes that

* lint the code
  • Loading branch information
lubiah committed Sep 7, 2023
1 parent fce0660 commit 6671834
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 6 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"lint-staged": "^13.1.0",
"prettier": "^2.8.2",
"prettier-plugin-svelte": "^2.9.0",
"schema-dts": "^1.1.0",
"svelte": "^3.55.0",
"svelte-check": "^3.0.1",
"tslib": "^2.4.1",
Expand All @@ -50,5 +49,8 @@
"lint-staged": {
"*.svelte": "prettier --write",
"*.{js,svelte}": "eslint --cache --fix"
},
"dependencies": {
"schema-dts": "^1.1.2"
}
}
4 changes: 2 additions & 2 deletions src/lib/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@
{/if}

{#if jsonLd}
{@const data = Object.assign({}, jsonLd)}
{@const data = Object.assign({ "@context": "https://schema.org" }, jsonLd)}
{@html `<script type="application/ld+json">${
JSON.stringify({ "@context": "https://schema.org", data }) + "<"
JSON.stringify(data) + "<"
}/script>`}
{/if}

Expand Down

0 comments on commit 6671834

Please sign in to comment.