From 310e51dd13bf6494a4c6b885335ab060325a300b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 12 Aug 2020 16:22:42 +0200 Subject: [PATCH] Add a mix task to generate a sitemap Signed-off-by: Thomas Citharel --- lib/mix/tasks/mobilizon/site_map.ex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/mix/tasks/mobilizon/site_map.ex diff --git a/lib/mix/tasks/mobilizon/site_map.ex b/lib/mix/tasks/mobilizon/site_map.ex new file mode 100644 index 000000000..ef4162892 --- /dev/null +++ b/lib/mix/tasks/mobilizon/site_map.ex @@ -0,0 +1,21 @@ +defmodule Mix.Tasks.Mobilizon.SiteMap do + @moduledoc """ + Task to generate a new Sitemap + """ + use Mix.Task + + alias Mix.Tasks.Mobilizon.Common + alias Mobilizon.Service.SiteMap + alias Mobilizon.Web.Endpoint + + @preferred_cli_env "prod" + + @shortdoc "Generates a new Sitemap" + def run(["generate"]) do + Common.start_mobilizon() + + with {:ok, :ok} <- SiteMap.generate_sitemap() do + Mix.shell().info("Sitemap saved to #{Endpoint.url()}/sitemap.xml") + end + end +end