Skip to content

Commit

Permalink
feat: global components (#164)
Browse files Browse the repository at this point in the history
* feat(lib): register nuxt components:dirs hook

* chore(deps): use nuxt v2.13.x

* chore(example): use global components

* chore(docs): use global components

* docs: add section about global components

* Update docs/package.json

Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>

* docs: update global components

* Update writing.md

* chore: remove commitlint

* docs: update deps

* chore(deps): update

* chore(github): add ci on dev branch

Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
  • Loading branch information
benjamincanac and atinux committed Jul 2, 2020
1 parent c40ef02 commit 0c62147
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 271 deletions.
55 changes: 5 additions & 50 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`, `.xml` files and generate the following properties:
This module will parse `.md`, `.yaml`, `.yml`, `.csv`, `.json`, `.json5` 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[server.js]
```html
<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 of 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 on code blocks.
### Syntax highlighting

Expand Down Expand Up @@ -315,7 +315,7 @@ However, you cannot render

#### 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.
Since **v2.0.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/
Expand Down Expand Up @@ -428,7 +428,7 @@ Will be transformed into:
"dir": "/",
"slug": "home",
"path": "/home",
"extension": ".csv",
"extension": ".json",
"body": [
{
"title": "Home",
Expand All @@ -438,51 +438,6 @@ 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
Loading

0 comments on commit 0c62147

Please sign in to comment.