asciidoctor / jekyll-asciidoc

:syringe: A Jekyll plugin that converts AsciiDoc source files in your site to HTML pages using Asciidoctor.
https://github.com/asciidoctor/jekyll-asciidoc
MIT License
307 stars 80 forks source link

Per-scope asciidoctor attribute values #134

Open akomakom opened 7 years ago

akomakom commented 7 years ago

Is it possible to provide different attribute values per jekyll scope?

ie:

asciidoctor:
  attributes:
     - imagesdir='/images'
defaults:
  -
    values:
      layout: "default"
  -
    scope:
      path: "asciidoctor1/subdirectory"
      type: "pages"
    values:
      layout: "custom"
      asciidoctor:
        attributes:
            imagesdir: "/different/path"

Which would override the value of imagesdir specified in asciidoctor->attributes for the given path?

Alternatively, all scope values could be blindly made available to asciidoctor:

defaults:
  -
    values:
      layout: "default"
  -
    scope:
      path: "asciidoctor1/subdirectory"
      type: "pages"
    values:
      layout: "custom"
      imagesdir: "/different/path"

(just two examples of possible syntax).

At this time I'm finding that the scope concept is entirely disconnected from asciidoctor configuration - there is no way to reference values between them in either direction (being able to reference them would be another way to reduce duplicated configuration)

If there is a way to do any of the above already, please point me in the right direction.

mojavelinux commented 5 years ago

The layout part of this issue was reported again in #187 and a solution has been found.

Built-in AsciiDoc attributes such as imagesdir cannot yet be defined per scope. They can only be defined globally or in the document itself.

lorrden commented 9 months ago

I'd guess this is related, I managed to enable asciidoctor-bibtex on my Jekyll site, but apparently the bibtex-file-attribute has to be set globally and cannot be set on a per document basis. So it is only possible to have one bibliography file for the whole site, which does not scale well.

mojavelinux commented 9 months ago

Have you tried the soft set (@) modifier? https://docs.asciidoctor.org/asciidoc/latest/attributes/assignment-precedence/#altering-the-assignment-precedence