16 lines
474 B
1
defmodule Mix.Tasks.MakePost do
2
use Mix.Task
3
4
def run(args) do
5
[title, tags] = args
6
[date, time] = "#{DateTime.utc_now()}" |> String.split(" ")
7
[time | _] = time |> String.replace(":", "-") |> String.split(".")
8
fname = date <> "-" <> time
9
path = "priv/static/posts/"
10
file = fname <> "-" <> title <> ".md"
11
body = "tags: " <> tags <> "\n"
12
full_path = path <> file
13
File.write(full_path, body)
14
IO.puts("Wrote #{full_path}")
15
end
16
end
17