0.7.1 • Published 3 months ago

@bkwld/json-ld-formatters v0.7.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

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.

0.7.1

3 months ago

0.7.0

4 months ago

0.6.0

1 year ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago