Display favicons for external links
This commit is contained in:
12
assets/content.js
Normal file
12
assets/content.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
(function () {
|
||||||
|
document.querySelectorAll('.content a[href^="http"]').forEach(function (a) {
|
||||||
|
var hostname = new URL(a.href).hostname;
|
||||||
|
var img = document.createElement('img');
|
||||||
|
img.src = 'https://icons.duckduckgo.com/ip3/' + hostname + '.ico';
|
||||||
|
img.width = 16;
|
||||||
|
img.height = 16;
|
||||||
|
img.style.verticalAlign = 'middle';
|
||||||
|
img.style.marginRight = '3px';
|
||||||
|
a.prepend(img);
|
||||||
|
});
|
||||||
|
})();
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
<script src="/_/editor.js"></script>
|
<script src="/_/editor.js"></script>
|
||||||
{{else}} {{if .Content}}
|
{{else}} {{if .Content}}
|
||||||
<div class="content">{{.Content}}</div>
|
<div class="content">{{.Content}}</div>
|
||||||
|
<script src="/_/content.js"></script>
|
||||||
{{end}} {{if .Entries}}
|
{{end}} {{if .Entries}}
|
||||||
<div class="listing">
|
<div class="listing">
|
||||||
<div class="listing-header">Contents</div>
|
<div class="listing-header">Contents</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user