-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.jl
53 lines (51 loc) · 1.81 KB
/
utils.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Add a sister pager to support pre-v1.0 Franklin paths
# This is needed for all blog posts released prior to Jun 1, 2020
# Usage: {{ add_sister }}
function hfun_add_sister()
rpath = splitext(locvar(:fd_rpath))[1] # path/file
sister_url = rpath * ".html" # path/file.html
redirect_html =
"""
<!-- REDIRECT -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=/$rpath/" />
</head>
</html>
"""
write(joinpath("__site", sister_url), redirect_html)
return ""
end
function hfun_disqus()
id = locvar(:page_id)
s = """
<hr>
<div id="disqus_thread">
<div id="disqus_thread_loader">Loading Comments...</div>
</div>
<script>
var disqus_config = function () {
this.page.url = window.location.href;
this.page.identifier = '$id';
};
var disqus_observer = new IntersectionObserver(function(entries) {
// comments section reached
// start loading Disqus now
if(entries[0].isIntersecting) {
(function() {
var d = document, s = d.createElement('script');
s.src = 'https://ahsmart.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
// once executed, stop observing
disqus_observer.disconnect();
}
}, { threshold: [0] });
disqus_observer.observe(document.querySelector("#disqus_thread"));
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
"""
return s
end