Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Sep 23, 2023
1 parent 568523c commit 95b3c89
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ This configuration will set the constructor option for Marp Core as specified:
</details>

### Type annotation
### Auto completion

For getting better IDE support (such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense)) to write a config, you can annotate the config object through JSDoc, with Marp CLI's `Config` type.
For getting the power of auto completion for the config, such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense), you can annotate the config object through JSDoc, with Marp CLI's `Config` type.

```javascript
/** @type {import('@marp-team/marp-cli').Config} */
Expand All @@ -634,9 +634,19 @@ const config = {
export default config
```

Or you can use Vite-like `defineConfig` helper from Marp CLI instead.

```javascript
import { defineConfig } from '@marp-team/marp-cli'

export default defineConfig({
// ...
})
```

#### `Config` type with custom engine

If you've swapped the engine into another Marpit based engine, you also can provide better suggestion for `options` field by passing the engine type to generics.
If you've swapped the engine into another Marpit based engine, you can provide better suggestion for `options` field by passing the engine type to generics.

```javascript
/** @type {import('@marp-team/marp-cli').Config<typeof import('@marp-team/marpit').Marpit>} */
Expand All @@ -650,6 +660,25 @@ const config = {
export default config
```

#### TypeScript (`marp.config.ts`)

If you installed `typescript` into your local project together with Marp CLI, you can write a config by TypeScript `marp.config.ts`. Marp CLI will try to transpile `.ts` with the project configuration `tsconfig.json`.

In TypeScript configuration, you can specify the custom engine as the generics for `defineConfig` helper, like this:

```typescript
// marp.config.ts
import { Marpit } from '@marp-team/marpit'
import { defineConfig } from '@marp-team/marp-cli'

export default defineConfig<typeof Marpit>({
engine: Marpit,
options: {
// Suggest only Marpit constructor options
},
})
```

## API _(EXPERIMENTAL)_

You can use Marp CLI through Node.js [if installed Marp CLI into your local project](#local-installation).
Expand Down

0 comments on commit 95b3c89

Please sign in to comment.