Re: setting imagesdir for asciidoc articles baked with awestruct
Posted by xcoulon on Aug 28, 2013; 8:29am
URL: https://discuss.asciidoctor.org/setting-imagesdir-for-asciidoc-articles-baked-with-awestruct-tp528p531.html
Hi Jason
Thanks for your reply, I'll try that solution.
Yesterday, I found a workaround by creating a custom extension which extends the Posts class:
module Awestruct
module Extensions
class MyPosts < Posts
def initialize(path_prefix='', assign_to=:posts, archive_template=nil, archive_path=nil, opts={})
super(path_prefix, assign_to, archive_template, archive_path, opts)
@imagesdir = opts[:imagesdir] || '/images'
puts "Initialized MyPosts extension with imagesdir=" + @imagesdir
end
def execute(site)
super(site)
site.posts.each do |page|
page.imagesdir = site.base_url + @imagesdir
end
end
end
end
end
This is convenient because the imagesdir property is configured in the pipeline.rb for all the blog posts, so this does not need to be configured in each article.
Best regards,