Created
April 20, 2017 21:20
-
-
Save myobie/08cfac28f9216f8cf99a41f410839aa4 to your computer and use it in GitHub Desktop.
Elixir code to generate a json file of all the svg slides in a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curry the write function | |
write_data = &(File.write!("./assets/slides.json", &1)) | |
Path.wildcard("./assets/slides/*.svg") | |
|> Enum.sort() | |
|> Enum.map(&Path.basename/1) | |
|> Enum.with_index(1) | |
|> Enum.map(fn {file, index} -> {file, Path.basename(file, ".svg"), index} end) | |
|> Enum.map(fn {file, name, index} -> | |
%{ | |
number: index, | |
name: name, | |
path: "/assets/slides/#{file}" | |
} | |
end) | |
|> Poison.encode!() | |
|> write_data.() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment