feat: Ping search engines

This commit is contained in:
Robert Prehn 2023-10-26 13:16:43 +00:00
parent 94d34abc93
commit ad3846be2f
No known key found for this signature in database
2 changed files with 25 additions and 0 deletions

View file

@ -15,3 +15,8 @@ pages:
artifacts:
paths:
- public
ping:
needs:
- "pages:deploy"
script:
- mix pre_dot_hn.ping

View file

@ -0,0 +1,20 @@
defmodule Mix.Tasks.PreDotHn.Ping do
use Mix.Task
@urls [
"http://google.com/ping?sitemap=%s",
"http://www.bing.com/webmaster/ping.aspx?sitemap=%s"
]
def ping(sitemap_url) do
@urls
|> Enum.map(fn url ->
ping_url = String.replace(url, "%s", sitemap_url)
:httpc.request('#{ping_url}')
end)
end
def run(_args) do
ping("https://pre.hn/sitemap.xml.gz")
end
end