https://github.com/netsells/nuxt-meta-builder
https://github.com/netsells/nuxt-meta-builder
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/netsells/nuxt-meta-builder
- Owner: netsells
- License: mit
- Created: 2019-01-16T10:12:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-13T13:12:03.000Z (about 3 years ago)
- Last Synced: 2024-09-23T10:07:55.261Z (8 months ago)
- Language: JavaScript
- Size: 1.41 MB
- Stars: 3
- Watchers: 7
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nuxt Meta Builder
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
> A fluent approach to building up the meta data object within a Nuxt project
Created and maintained by the [Netsells team](https://netsells.co.uk/)
## Why?
The standard approach to building up the meta content powered by [vue-meta](https://www.npmjs.com/package/vue-meta) is to manually create an object with keys and values and is often a repeated mess across pages. This approach makes this a bit more readable via fluent methods.
## Installation
```sh
yarn add @netsells/nuxt-meta-builder
```## Usage
Add the module to your nuxt config's `modules` array:
```js
module.exports = {
...
modules: [
'@netsells/nuxt-meta-builder',
],
...
};
```You can then access the `$metaBuilder` function on the Vue instance:
```vue
export default {
// Basic usage
head() {
return this.$metaBuilder()
.setTitle('My page title')
.setDescription('The description for the current page')
.make();
},
};```
## Available API Methods
| Method | Description | Arguments |
| --- | --- | --- |
| `setDescription` | Set both the `description` and the `og:description` meta data | `val` [required] - the description to set |
| `setTitle` | Set both the `title` and the `og:title` meta data | `hid` - the title to set
`content` [optional, default = false] - the title value to set |
| `addMeta` | Set specific meta values | `hid` [required] - the unique meta tag id to set. Can be a single `string` or an `array` of `string`s
`content` [required] - the meta value to set |
| `make` | Generate the resulting object | None. |Note: All public API methods return the class instance and can be chained, other than the `make` command which returns the final meta object and should be called last.
## License
MIT © [Netsells](https://www.netsells.co.uk)
[npm-image]: https://badge.fury.io/js/%40netsells%2Fnuxt-meta-builder.svg
[npm-url]: https://npmjs.org/package/@netsells/nuxt-meta-builder
[travis-image]: https://travis-ci.org/netsells/nuxt-meta-builder.svg?branch=master
[travis-url]: https://travis-ci.org/netsells/nuxt-meta-builder
[daviddm-image]: https://david-dm.org/netsells/nuxt-meta-builder.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/netsells/nuxt-meta-builder