# trailpack-jsonld

> Data is messy and disconected, JSON-LD organize and connects it, creating a better Web.

Latest version **0.0.2-alpha-2** (published 2016-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install trailpack-jsonld
pnpm add trailpack-jsonld
yarn add trailpack-jsonld
bun add trailpack-jsonld
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2-alpha-2 |
| Published | 2016-02-20 |
| First published | 2016-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Mehdi Aissani |
| Maintainers | maissani |
| Keywords | trailpack, trails, trailjs |

## Links

- npm: https://www.npmjs.com/package/trailpack-jsonld
- Repository: https://github.com/maissani/trailpack-jsonld
- Issues: https://github.com/maissani/trailpack-jsonld/issues
- npm.io page: https://npm.io/package/trailpack-jsonld

## Dependencies (4)

- [jsonld](https://npm.io/package/jsonld.md) ^0.4.5
- [lodash](https://npm.io/package/lodash.md) ^4.5.0
- [trailpack](https://npm.io/package/trailpack.md) latest
- [trails-service](https://npm.io/package/trails-service.md) ^1.0.0-alpha-1

## Recent versions

- 0.0.2-alpha-2 (latest) — 2016-02-20
- 0.0.1 — 2016-02-19

## README

# trailpack-jsonld
[![Gitter][gitter-image]][gitter-url]
[![NPM version][npm-image]][npm-url]
[![NPM downloads][npm-download]][npm-url]
[![Build status][ci-image]][ci-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![Code Climate][codeclimate-image]][codeclimate-url]

:package: Add a Trails service to warp jsonld features

This package is an implementation of [jsonld](https://github.com/digitalbazaar/jsonld.js) in Trails framework.

For the moment it's just a wrapper but in a short amount of time it will symplify the json-ld calls

## Intallation
With yo : 

```
npm install -g yo generator-trails
yo trails:trailpack trailpack-jsonld
```

With npm (you will have to create config file manually) :
 
`npm install --save trailpack-jsonld`

## Configuration
Enable JsonLD
```js
// config/main.js

  packs: [
    ...
    require('trailpack-jsonld')
  ],
```
Check that jsonld config is loaded on index.js
```js
// config/index.js
...
exports.srcds = require('./jsonld')
```

Configure
```js
// config/jsonld.js

module.exports = {

  dictionaries: [{
    name: "schema.org",
    url: "http://schema.org"
  }],

  defaultDictonary: "schema.org"
}

```


## Usage



### Quick Examples

```js
let jsonldLegacyService = this.app.services.JsonldService.legacy()

var doc = {
  "http://schema.org/name": "Manu Sporny",
  "http://schema.org/url": {"@id": "http://manu.sporny.org/"},
  "http://schema.org/image": {"@id": "http://manu.sporny.org/images/manu.png"}
};
var context = {
  "name": "http://schema.org/name",
  "homepage": {"@id": "http://schema.org/url", "@type": "@id"},
  "image": {"@id": "http://schema.org/image", "@type": "@id"}
};

// compact a document according to a particular context
// see: http://json-ld.org/spec/latest/json-ld/#compacted-document-form

jsonldLegacyService.compact(doc, context, function(err, compacted) {
  console.log(JSON.stringify(compacted, null, 2));
  /* Output:
  {
    "@context": {...},
    "name": "Manu Sporny",
    "homepage": "http://manu.sporny.org/",
    "image": "http://manu.sporny.org/images/manu.png"
  }
  */
});
```
For more information check the jsonld repo to see the possibilities : [here](https://github.com/digitalbazaar/jsonld.js) 


## License
A part of this docs are owned by Digitalbazaar the creator of jsonld package.

[MIT](https://github.com/jaumard/trailpack-jsonld/blob/master/LICENSE)

[npm-image]: https://img.shields.io/npm/v/trailpack-jsonld.svg?style=flat-square
[npm-url]: https://npmjs.org/package/trailpack-jsonld
[npm-download]: https://img.shields.io/npm/dt/trailpack-jsonld.svg
[ci-image]: https://travis-ci.org/maissani/trailpack-jsonld.svg?branch=master
[ci-url]: https://travis-ci.org/maissani/trailpack-jsonld
[daviddm-image]: http://img.shields.io/david/maissani/trailpack-jsonld.svg?style=flat-square
[daviddm-url]: https://david-dm.org/maissani/trailpack-jsonld
[codeclimate-image]: https://img.shields.io/codeclimate/github/maissani/trailpack-jsonld.svg?style=flat-square
[codeclimate-url]: https://codeclimate.com/github/maissani/trailpack-jsonld
[gitter-image]: http://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square
[gitter-url]: https://gitter.im/trailsjs/trails

---
_Source: https://npm.io/package/trailpack-jsonld · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
