@bkwld/json-ld-formatters

0.7.1 • Public • Published

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.

<!-- pages/_article.vue -->
<script lang='coffee'>
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 }

</script>

Formatters

Read the source code for the available formatters and their expected properties.

Readme

Keywords

none

Package Sidebar

Install

npm i @bkwld/json-ld-formatters

Weekly Downloads

246

Version

0.7.1

License

MIT

Unpacked Size

67.9 kB

Total Files

16

Last publish

Collaborators

  • azerozvn
  • lemoswilson
  • sjstark
  • weotch
  • mattaebersold
  • isaazgarcia
  • brokenhd