0.3.0 • Published 2 years ago

astro-adoc v0.3.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 years ago

astro-adoc

Integrate AsciiDoctor content into your Astro project.

Usage

For example, to get the following routes:

DirectoryURL
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:

---
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.

---
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 library, so you can pass any option that works with that library.

See convert options for more information.

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

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.1.1

2 years ago