Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/hexdocs/file_rewriter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Hexdocs.FileRewriter do
@link_hooks [@link_hook1, @link_hook2]

@analytics_hook ~s|</head>|
@analytics_addition ~s|<script async defer data-domain="${DOMAIN}" src="https://stats.${DOMAIN}/js/script.js" onerror="console.warn('failed to load:', this.src)"></script>|
@analytics_addition "<script async defer src=\"https://s.${DOMAIN}/js/script.js\"></script><script>window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init({endpoint:\"https://s.${DOMAIN}/api/event\"})</script>"

@noindex_hook ~s|<meta name="robots" content="noindex">|

Expand Down
4 changes: 2 additions & 2 deletions test/hexdocs/file_rewriter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ defmodule Hexdocs.FileRewriterTest do
test "run/1" do
assert FileRewriter.run("index.html", "") == ""

assert FileRewriter.run("index.html", "</head>") =~
~s|<script async defer data-domain="localhost" src="https://stats.localhost/js/script.js"|
assert FileRewriter.run("index.html", "</head>") ==
"<script async defer src=\"https://s.localhost/js/script.js\"></script><script>window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init({endpoint:\"https://s.localhost/api/event\"})</script></head>"

assert FileRewriter.run(
"index.html",
Expand Down