https://github.com/bkwld/json-ld-formatters
A library of helper functions for creating common JSON LD schemas.
https://github.com/bkwld/json-ld-formatters
json-ld nuxt
Last synced: 2 months ago
JSON representation
A library of helper functions for creating common JSON LD schemas.
- Host: GitHub
- URL: https://github.com/bkwld/json-ld-formatters
- Owner: BKWLD
- License: mit
- Created: 2022-02-18T02:39:58.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-20T23:30:14.000Z (over 2 years ago)
- Last Synced: 2025-03-05T10:02:05.662Z (over 1 year ago)
- Topics: json-ld, nuxt
- Language: CoffeeScript
- Homepage:
- Size: 70.3 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-ld-formatters
A library of helper functions for creating common JSON LD schemas. These are intended to be used in Nuxt.js projects.
## Install
```
yarn add @bkwld/json-ld-formatters
```
## Example
Here's how you would use this in a typical Cloak page component.
```vue
import pageMixin from '@bkwld/cloak/mixins/page'
import { makeJsonLdArticleTag } from '@bkwld/json-ld-formatters'
export default
# Add Cloak's pageMixin to the example. This isn't necessary, but I think
# it useful to show how you would use @buildHead to mash up other meta / SEO
# data with this
mixins: [ pageMixin ]
# Here's where the use the formatter
head: -> {
...@buildHead
title: @page.marqueeTitle
script: [ makeJsonLdArticleTag
title: @page.marqueeTitle
image: @page.image
publishedAt: new Date @page.dateCreated
updatedAt: new Date @page.dateUpdated
author: 'Bukwild'
]
}
# Showing an example of fetching page data
asyncData: ({ app, route }) ->
page = await app.$service.getPageData route.params.article
return { page }
```
## Formatters
Read the source code for the available formatters and their expected properties.
- [article](./formatters/article.coffee) - `makeJsonLdArticleTag`
- [breadcrumbs](./formatters/breadcrumbs.coffee) - `makeJsonLdBreadcrumbsTag`
- [faqPage](./formatters/faqPage.coffee) - `makeJsonLdFAQPageTag`
- [organization](./formatters/organization.coffee) - `makeJsonLdOrganizationTag`
- [product](./formatters/product.coffee) `makeJsonLdProductTag`
- [search](./formatters/search.coffee) - `makeJsonLdSearchTag`