Skip to content

Commit e267c5b

Browse files
authored
Update Plausible script (#62)
1 parent 4ee564c commit e267c5b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/hexdocs/file_rewriter.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Hexdocs.FileRewriter do
55
@link_hooks [@link_hook1, @link_hook2]
66

77
@analytics_hook ~s|</head>|
8-
@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>|
8+
@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>"
99

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

test/hexdocs/file_rewriter_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ defmodule Hexdocs.FileRewriterTest do
55
test "run/1" do
66
assert FileRewriter.run("index.html", "") == ""
77

8-
assert FileRewriter.run("index.html", "</head>") =~
9-
~s|<script async defer data-domain="localhost" src="https://stats.localhost/js/script.js"|
8+
assert FileRewriter.run("index.html", "</head>") ==
9+
"<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>"
1010

1111
assert FileRewriter.run(
1212
"index.html",

0 commit comments

Comments
 (0)