# astro-adoc

> AsciiDoctor inside Astro

Latest version **0.3.0** (published 2022-10-07) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install astro-adoc
pnpm add astro-adoc
yarn add astro-adoc
bun add astro-adoc
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-10-07 |
| First published | 2022-09-25 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 40.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | David Wolf |
| Maintainers | devidw |
| Keywords | astro-component, astro-integration, withastro, asciidoctor, asciidoc, adoc |

## Links

- npm: https://www.npmjs.com/package/astro-adoc
- Repository: https://github.com/devidw/astro-addons
- Homepage: https://github.com/devidw/astro-addons/tree/main/packages/astro-adoc#readme
- Issues: https://github.com/devidw/astro-addons/issues
- npm.io page: https://npm.io/package/astro-adoc

## Dependencies (1)

- [asciidoctor](https://npm.io/package/asciidoctor.md) ^2.2.6

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2022-10-07
- 0.2.4 — 2022-10-07
- 0.2.3 — 2022-09-26
- 0.2.2 — 2022-09-26
- 0.2.1 — 2022-09-26
- 0.1.1 — 2022-09-25

## README

# astro-adoc

Integrate AsciiDoctor content into your Astro project.

## Usage

For example, to get the following routes:

| Directory | URL
| --- | ---
| `src/articles/post.adoc` | `/blog/post`
| `src/articles/sub/index.adoc` | `/blog/sub`
| `src/articles/dig/deeper.adoc` | `/blog/dig/deeper`

Your would add the following to `src/pages/blog/[...slug].astro`:

```astro
---
import { getAdocPaths } from "astro-adoc"
import { AsciiDoctor } from "astro-adoc/components"

export async function getStaticPaths() {
  return await getAdocPaths("src/articles", "slug")
}

const { slug } = Astro.params
---

<AsciiDoctor path={`src/articles/${slug}`} />
```

Beside the `slug` from `Astro.params`, you also get `adoc` from `Astro.props`
which is the parsed AsciiDoctor document.

If you want more control over the layout, you can use the `getAdoc` function
instead of the `AsciiDoctor` component.

You can access anything from the returning `AsciiDoctor.Document` instance you want to display.

```astro
---
import { getAdocPaths } from "astro-adoc"
import type { Asciidoctor } from "asciidoctor"

export async function getStaticPaths() {
  return await getAdocPaths("src/articles")
}

const { adoc } = Astro.props as { adoc: Asciidoctor.Document }
---

<h1>
  {adoc.getTitle()}
</h1>

{adoc.getAuthor()}

<Fragment set:html={adoc.convert()} />
```

## Configuration

The integrations wraps the [asciidoctor.js](https://docs.asciidoctor.org/asciidoctor.js/) library, so you can pass any option
that works with that library.

See [_convert options_](https://docs.asciidoctor.org/asciidoctor.js/latest/processor/convert-options/) for more information.

```astro
<AsciiDoctor
  path={`src/articles/article`}
  options={{ attributes: { showtitle: true } }}
/>
```

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