Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.0 #189

Merged
merged 9 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ on:
pull_request:
branches:
- master
- dev

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
node: [12]

steps:
Expand Down
5 changes: 0 additions & 5 deletions commitlint.config.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>

<script>
import ClickAway from '../directives/click-away'
import ClickAway from '~/directives/click-away'

export default {
name: 'Dropdown',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<div
class="alert border-l-4 p-4 mb-4"
:class="`alert-${type}`"
>
<div class="alert border-l-4 p-4 mb-4" :class="`alert-${type}`">
<div class="flex">
<div class="flex-shrink-0 self-start pt-1">
<IconInfo v-if="type === 'info'" class="alert-icon" />
Expand Down
File renamed without changes.
22 changes: 0 additions & 22 deletions docs/content/en/changelog.md

This file was deleted.

29 changes: 25 additions & 4 deletions docs/content/en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ content: {

- Type `Array`
- Default: `[]`
- Version: **v1.3.0**
- Version: **>= v1.3.0**

Register nested properties to handle dot-notation and deep filtering.

Expand Down Expand Up @@ -199,18 +199,30 @@ export default {

- Type: `Array`
- Default: `['remark-squeeze-paragraphs', 'remark-slug', 'remark-autolink-headings', 'remark-external-links', 'remark-footnotes']`
- Version: **v2.0.0**
- Version: **>= v1.4.0**

> You can take a look at the list of [remark plugins](https://github.com/remarkjs/remark/blob/master/doc/plugins.md#list-of-plugins).

### `markdown.rehypePlugins`

- Type: `Array`
- Default: `['rehype-minify-whitespace', 'rehype-sort-attribute-values', 'rehype-sort-attributes', 'rehype-raw']`
- Version: **v2.0.0**
- Version: **>= v1.4.0**

> You can take a look at the list of [rehype plugins](https://github.com/rehypejs/rehype/blob/master/doc/plugins.md#list-of-plugins).

### `markdown.basePlugins`

<base-alert>
Deprecated. Use `markdown.remarkPlugins` as a function instead.
</base-alert>

### `markdown.plugins`

<base-alert>
Deprecated. Use `markdown.remarkPlugins` as an array instead.
</base-alert>

### `markdown.prism.theme`

- Type: `String`
Expand Down Expand Up @@ -251,6 +263,14 @@ This module uses `js-yaml` to parse `.yaml`, `.yml` files, you can check here fo

Note that we force `json: true` option.


### `xml`

- Type: `Object`
- Default: `{}`

This module uses `xml2js` to parse `.xml` files, you can check here for [options](https://www.npmjs.com/package/xml2js#options).

### `csv`

- Type: `Object`
Expand Down Expand Up @@ -286,7 +306,8 @@ export default {
}
},
yaml: {},
csv: {}
csv: {},
xml: {}
}
}
```
2 changes: 1 addition & 1 deletion docs/content/en/displaying.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can find an example in the [docs directory](https://github.com/nuxt/content/

## Live Editing

> Available since v2.0
> Available in version **>= v1.4.0**

**In development**, you can edit your content by **double-clicking** on the `<nuxt-content>` component. A textarea will allow you to edit the content of the current file and will save it on the file-system.

Expand Down
26 changes: 21 additions & 5 deletions docs/content/en/fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ This module globally injects `$content` instance, meaning that you can access it
- `options`
- Type: `Object`
- Default: `{}`
- Version: **v1.3.0**
- Version: **>= v1.3.0**
- `options.deep`
- Type: `Boolean`
- Default: `false`
- Version: **v1.3.0**
- Version: **>= v1.3.0**
- *Fetch files from subdirectories*
- `options.text`
- Type: `Boolean`
- Default: `false`
- Version: **v2.0.0**
- Version: **>= v1.4.0**
- *Returns the original markdown content in a `text` variable*
- Returns a chain sequence

Expand Down Expand Up @@ -90,7 +90,7 @@ const products = await this.$content('products').where({ 'categories.slug': { $c
const products = await this.$content('products').where({ 'categories.slug': { $contains: ['top', 'woman'] } }).fetch()
```

This module uses LokiJS under the hood, you can check for [query examples](https://github.com/techfort/LokiJS/wiki/Query-Examples#find-queries).
> This module uses LokiJS under the hood, you can check for [query examples](https://github.com/techfort/LokiJS/wiki/Query-Examples#find-queries).

### sortBy(key, direction)

Expand Down Expand Up @@ -235,4 +235,20 @@ Will expose on `localhost:3000`:

The endpoint is accessible on `GET` and `POST` request, so you can use query params: [http://localhost:3000/_content/articles?only=title&only=description&limit=10](http://localhost:3000/_content/articles?only=title&only=description&limit=10).

You can learn more about that endpoint in [lib/middleware.js](https://github.com/nuxt/content/blob/master/lib/middleware.js).
Since **v1.4.0**, this endpoint also support `where` in query params:

- All the keys that doesn't belong to any of the default ones will be applied to `where`

`http://localhost:3000/_content/articles?author=...`

- You can use `$operators` with `_`:

`http://localhost:3000/_content/articles?author_regex=...`

> This module uses LokiJS under the hood, you can check for [query examples](https://github.com/techfort/LokiJS/wiki/Query-Examples#find-queries).

- You can use [nested properties](/configuration#nestedproperties):

`http://localhost:3000/_content/products?categories.slug_contains=top`

> You can learn more about that endpoint in [lib/middleware.js](https://github.com/nuxt/content/blob/master/lib/middleware.js).
4 changes: 2 additions & 2 deletions docs/content/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ features:
- Powerful QueryBuilder API (MongoDB like)
- Syntax highlighting to code blocks in markdown files using PrismJS.
- Table of contents generation
- Handles Markdown, CSV, YAML, JSON(5)
- Handles Markdown, CSV, YAML, JSON(5), XML
- Extend with hooks
csb_link: https://codesandbox.io/embed/nuxt-content-l164h?hidenavigation=1&theme=dark
---

Empower your NuxtJS application with `@nuxt/content` module: write in a `content/` directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a **Git-based Headless CMS**.
Empower your NuxtJS application with `@nuxt/content` module: write in a `content/` directory and fetch your Markdown, JSON, YAML, XML and CSV files through a MongoDB like API, acting as a **Git-based Headless CMS**.

## Features

Expand Down
65 changes: 62 additions & 3 deletions docs/content/en/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ content/
home.md
```

This module will parse `.md`, `.yaml`, `.yml`, `.csv`, `.json`, `.json5` files and generate the following properties:
This module will parse `.md`, `.yaml`, `.yml`, `.csv`, `.json`, `.json5`, `.xml` files and generate the following properties:

- `dir`
- `path`
Expand Down Expand Up @@ -164,7 +164,7 @@ http.createServer((req, res) => {

After rendering with the `nuxt-content` component, it will look like this:

```html
```html[server.js]
<div class="nuxt-content-highlight">
<span class="filename">server.js</span>
<pre class="language-js" data-line="1,3-5">
Expand All @@ -177,7 +177,7 @@ After rendering with the `nuxt-content` component, it will look like this:

> Line numbers are added to the `pre` tag in `data-line` attribute.

> The filename will be converted to a span with a `filename` class, it's up to you to style it. Take a look at this documentation, on the top right on code blocks.
> The filename will be converted to a span with a `filename` class, it's up to you to style it. Take a look at this documentation, on the top right of code blocks.

### Syntax highlighting

Expand Down Expand Up @@ -313,6 +313,20 @@ However, you cannot render
</my-component>
```

#### Global components

Since **v1.4.0** and Nuxt **v2.13.0**, you can now put your components in `components/global/` directory so you don't have to import them in your pages.

```bash
components/
global/
Hello.vue
content/
home.md
```

Then in `content/home.md`, you can use `<hello></hello>` component without having to worry about importing it in your page.

### Table of contents

A `toc` array property will be injected into your document, listing all the `h2` and `h3` with their titles and ids, so you can link to them.
Expand Down Expand Up @@ -424,6 +438,51 @@ Will be transformed into:
}
```

## XML

XML will be parsed

### Example

A file `content/home.xml`:

```xml
<xml>
<item prop="abc">
<title>Title</title>
<description>Hello World</description>
</item>
</xml>
```

Will be transformed into:

```json
{
"dir": "/",
"slug": "home",
"path": "/home",
"extension": ".xml",
"body": {
"xml": {
"item": [
{
"$": {
"prop": "abc"
},
"title": [
"Title"
],
"description": [
"Hello World"
]
}
]
}
}
```


## YAML / YML

Data defined will be injected into the document.
Expand Down
21 changes: 0 additions & 21 deletions docs/content/ja/changelog.md

This file was deleted.

22 changes: 0 additions & 22 deletions docs/content/ru/changelog.md

This file was deleted.

File renamed without changes.
11 changes: 1 addition & 10 deletions docs/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default {
'@/plugins/categories',
'@/plugins/i18n.client',
'@/plugins/vue-scrollactive',
'@/plugins/components',
'@/plugins/menu.client'
],
components: true,
/*
** Give routes to static generation
*/
Expand Down Expand Up @@ -76,15 +76,6 @@ export default {
'@nuxt/content'
],
/*
** Components auto import
** See https://github.com/nuxt/components
*/
components: {
dirs: [
{ path: '@/components', pattern: '*.vue' }
]
},
/*
** Modules configuration
*/
colorMode: {
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
"dependencies": {
"@nuxt/content": "^1.3.2",
"@nuxt/content": "nuxt/content#dev",
"@nuxtjs/pwa": "^3.0.0-beta.20",
"lodash.groupby": "^4.6.0",
"nuxt-edge": "^2.13.0-26541346.39dd866b",
"nuxt": "^2.13.2",
"nuxt-i18n": "^6.12.2",
"prism-themes": "^1.4.0",
"tailwindcss": "^1.4.6",
Expand Down
Loading