Skip to content

Commit

Permalink
chore: update docus (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul authored May 29, 2021
1 parent 9cdf59c commit 0024f46
Show file tree
Hide file tree
Showing 15 changed files with 1,916 additions and 2,159 deletions.
13 changes: 0 additions & 13 deletions docs/content/settings.json

This file was deleted.

19 changes: 19 additions & 0 deletions docs/docus.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
title: '@nuxtjs/sanity',
twitter: 'nuxt_js',
url: 'https://sanity.nuxtjs.org',
theme: {
header: {
logo: {
dark: '/sanity-dark.svg',
light: '/sanity-light.svg',
},
title: false,
},
},
github: {
repo: 'nuxt-community/sanity-module',
branch: 'main',
dir: 'docs',
},
}
5 changes: 1 addition & 4 deletions docs/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { withDocus } from 'docus'

export default withDocus({
loading: { color: '#fa1607' },
generate: {
routes: ['/'],
},
rootDir: __dirname,
buildModules: ['vue-plausible'],
ackee: {
server: 'sanity.nuxtjs.org',
Expand Down
5 changes: 2 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"generate": "nuxt generate"
},
"devDependencies": {
"docus": "0.1.5",
"nuxt-edge": "2.16.0-27017293.a53fd32d",
"vue-plausible": "1.1.4"
"docus": "^0.5.14",
"vue-plausible": "^1.1.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
---
title: Quick start
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Getting started
position: 2
---

## Setup

1. **Install Sanity integration**

<d-code-group>
<d-code-block label="Yarn" active>
:::::code-group
::::code-block{label="Yarn" active}

```bash
yarn add @nuxtjs/sanity
```
```bash
yarn add @nuxtjs/sanity
```

</d-code-block>
<d-code-block label="NPM">
::::
::::code-block{label="NPM"}

```bash
npm install @nuxtjs/sanity --save
```
```bash
npm install @nuxtjs/sanity --save
```

</d-code-block>
</d-code-group>
::::
:::::

2. **Enable the module in your Nuxt configuration**

<d-code-group>
<d-code-block label="Nuxt 2.9+" active>
:::::code-group
::::code-block{label="Nuxt 2.9+" active}

```js{}[nuxt.config.js]
{
buildModules: ['@nuxtjs/sanity/module']
}
```
```js{}[nuxt.config.js]
{
buildModules: ['@nuxtjs/sanity/module']
}
```

</d-code-block>
<d-code-block label="Nuxt < 2.9">
::::
::::code-block{label="Nuxt < 2.9"}

```js{}[nuxt.config.js]
{
modules: ['@nuxtjs/sanity/module']
}
```
```js{}[nuxt.config.js]
{
modules: ['@nuxtjs/sanity/module']
}
```

</d-code-block>
</d-code-group>
::::
:::::

3. **Add Sanity configuration**

Expand All @@ -63,18 +61,20 @@ position: 2
}
```

<d-alert type="info">You can find more about configuring `@nuxtjs/sanity` [here](/configuration).</d-alert>
:::alert{type="info"}
You can find more about configuring `@nuxtjs/sanity` [here](/getting-started/configuration).
:::

4. **You're good to go!**

Check out [how to use Sanity](/usage).
Check out [how to use Sanity](/getting-started/usage).

## TypeScript

`@nuxtjs/sanity` offers type definitions. Just add an entry in `tsconfig.json`.

<d-code-group>
<d-code-block label="Nuxt 2.9+" active>
:::::code-group
::::code-block{label="Nuxt 2.9+" active}

```json{}[tsconfig.json]
{
Expand All @@ -84,8 +84,8 @@ position: 2
}
```

</d-code-block>
<d-code-block label="Nuxt < 2.9">
::::
::::code-block{label="Nuxt < 2.9"}

```json{}[tsconfig.json]
{
Expand All @@ -95,6 +95,5 @@ position: 2
}
```

</d-code-block>

</d-code-group>
::::
:::::
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Configuration
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Getting started
position: 3
version: 0.31
---

By default, `@nuxtjs/sanity` will look for a `sanity.json` file in your project root directory, and it will read your `projectId` and `dataset` from there.
Expand Down Expand Up @@ -87,7 +84,9 @@ Include credentials in requests made to Sanity. Useful if you want to take advan

Use an ultra-minimal Sanity client for making requests (a fork of [picosanity](https://github.com/rexxars/picosanity) with SSR-specific changes). It only supports `fetch` requests, but will significantly decrease your bundle size.

<d-alert type="info">If you don't have `@sanity/client` installed, then `@nuxtjs/sanity` will use the minimal client by default.</d-alert>
:::alert{type="info"}
If you don't have `@sanity/client` installed, then `@nuxtjs/sanity` will use the minimal client by default.
:::

### `imageHelper`

Expand Down Expand Up @@ -144,6 +143,6 @@ So, for example:
}
```

<d-alert>Because these clients will be accessible directly off the `$sanity` helper, take care not to name them `client`, `fetch` or `setToken`, or they will conflict with the default client properties.

</d-alert>
:::alert
Because these clients will be accessible directly off the `$sanity` helper, take care not to name them `client`, `fetch` or `setToken`, or they will conflict with the default client properties.
:::
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Usage
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Getting started
position: 4
version: 0.39
---

This module globally injects a `$sanity` helper, meaning that you can access it anywhere using `this.$sanity`. For plugins, asyncData, fetch, nuxtServerInit and middleware, you can access it from `context.$sanity`.
Expand All @@ -16,8 +13,8 @@ This enables you to perform a GROQ query against your Sanity dataset. By default

#### Example with `asyncData`

<d-code-group>
<d-code-block label="JavaScript" active>
:::::code-group
::::code-block{label="JavaScript" active}

```js
import { groq } from '@nuxtjs/sanity'
Expand All @@ -31,8 +28,8 @@ export default {
}
```

</d-code-block>
<d-code-block label="TypeScript">
::::
::::code-block{label="TypeScript"}

```ts
import { groq } from '@nuxtjs/sanity'
Expand All @@ -48,15 +45,17 @@ export default {
}
```

</d-code-block>
</d-code-group>
::::
:::::

<d-alert type="info">By wrapping the GROQ query into an object, you can return the promise directly. The data will be available in your component under the key used in the query.</d-alert>
:::alert{type="info"}
By wrapping the GROQ query into an object, you can return the promise directly. The data will be available in your component under the key used in the query.
:::

#### Example with `fetch`

<d-code-group>
<d-code-block label="JavaScript" active>
:::::code-group
::::code-block{label="JavaScript" active}

```js
import { groq } from '@nuxtjs/sanity'
Expand Down Expand Up @@ -89,8 +88,8 @@ export default {
}
```

</d-code-block>
</d-code-group>
::::
:::::

### `client`

Expand Down Expand Up @@ -140,7 +139,7 @@ export default ({ $sanity }, inject) => {

### Additional clients

If you have [configured additional clients](/configuration#additionalclients) you can access them directly off `$sanity`, with all the same properties and methods as specified above. So, for example:
If you have [configured additional clients](/getting-started/configuration#additionalclients) you can access them directly off `$sanity`, with all the same properties and methods as specified above. So, for example:

```js{}[plugins/fetch.js]
export default async ({ $sanity }) => {
Expand Down
20 changes: 10 additions & 10 deletions docs/content/en/index.md → docs/pages/en/1.index.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
---
title: Introduction
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: ''
position: 1
items:
- Just bring your sanity.json - no additional configuration required
- Ultra-lightweight Sanity client
- Zero-config image component
- Supports GROQ syntax highlighting
- Module and all dependencies < 1.7kB gzipped
- Written in TypeScript
---

<img src="/preview.png" class="light-img" alt="Access text, images, and other media with Nuxt and the Sanity headless CMS."/>
Expand All @@ -19,4 +10,13 @@ items:

## Features

<list :items="items"></list>
:::list

- Just bring your sanity.json - no additional configuration required
- Ultra-lightweight Sanity client
- Zero-config image component
- Supports GROQ syntax highlighting
- Module and all dependencies < 1.7kB gzipped
- Written in TypeScript

:::
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Portable text
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Helpers
position: 10
version: 0.51
---

## Global helper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Image formatting
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Helpers
position: 11
version: 0.51
---

## Global helper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Files
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Helpers
position: 12
version: 0.80
---

## Global helper
Expand Down Expand Up @@ -52,7 +49,10 @@ You may wish to import `SanityFile` only in the components that need it, if you

```vue
<template>
<SanityFile asset-id="file-41773b5c55bc5414ab7554a75eefddf8e2e14524-txt" download="myfile.txt">
<SanityFile
asset-id="file-41773b5c55bc5414ab7554a75eefddf8e2e14524-txt"
download="myfile.txt"
>
<template #default="{ src }">
<a :href="src">Click here to download</a>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
title: Syntax highlighting
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Helpers
position: 12
---

This module exports a `groq` helper function to assist with GROQ syntax highlighting and [eslint rules](https://github.com/asbjornh/eslint-plugin-groq). Make sure to install [the VSCode extension](https://github.com/sanity-io/vscode-sanity) - and enjoy!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
title: Credits
description: 'Access text, images, and other media with Nuxt and the Sanity headless CMS.'
category: Community
position: 31
---

Thanks to the following projects:
Expand Down
2 changes: 1 addition & 1 deletion docs/tailwind.config.js → docs/windi.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
theme: {
extend: {
colors: {
Expand Down
Loading

0 comments on commit 0024f46

Please sign in to comment.