Skip to content

Commit

Permalink
feat: dynamic-content-fallback template
Browse files Browse the repository at this point in the history
  • Loading branch information
limulus authored Oct 25, 2024
1 parent eb8327b commit fb30496
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions www/_includes/dynamic-content-fallback.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% assign fallbackHtml = '<p><em>View this dynamic content on the website with JavaScript enabled.</em></p>' %}

<noscript>
{{ fallbackHtml }}
</noscript>
<script>
// Ensure that syndicated copies of this content don’t show a "Loading…" message. This is
// necessary because some feed readers try to execute JavaScript.
const firstPartyHosts = ['limulus.net', 'localhost', '127.0.0.1']
if (firstPartyHosts.some((host) => window.location.host.includes(host))) {
document.write('<p><em>Loading…</em></p>')
} else {
document.write('{{ fallbackHtml | replace: "'", "\\'" }}')
}
</script>

0 comments on commit fb30496

Please sign in to comment.