0

I'm trying to write a Jekyll plugin which generates an array of pages in a directory in a json file. So for a directory which contains foo.html and a sub-directory foo containing bar.html, it'd generate "foo, /foo/bar". I'm completely new to Ruby, does somone have any pointers?

1 Answer 1

2

You can use globs and wildcards with Ruby's Dir class. You could get an array of .html files recursively from the current directory, using something along the lines of files = Dir['./**/*.html'].

To generate JSON, you'd want to first ensure that the person using your plugin has access to a JSON library (require 'json') and then use the #to_json helper method on your files array: files.to_json

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.