Skip to content

Commit

Permalink
load prism only on post layouts (fixes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
MyXoToD committed Apr 22, 2024
1 parent 5de4ef2 commit 6208293
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = (eleventyConfig) => {
eleventyConfig.addGlobalData('accentcolor', 'rebeccapurple');
eleventyConfig.addGlobalData('layout', 'base');
eleventyConfig.addGlobalData('topbar', true);
eleventyConfig.addGlobalData('include_prism', false);
eleventyConfig.addGlobalData('fallbackcover', '/assets/images/fallback-cover.webp');
eleventyConfig.addGlobalData('sitemap', {
'priority': 0.5
Expand Down
13 changes: 9 additions & 4 deletions src/_layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
<meta name="theme-color" content="{{ accentcolor }}">

<link rel="stylesheet" href="{{ '/assets/stylesheets/application.min.css' | url }}?v={{ site.builtAt }}" media="screen">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-okaidia.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-okaidia.css" media="screen"></noscript>
{% if include_prism %}
<link rel="preload" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-okaidia.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-okaidia.css" media="screen"></noscript>
{% endif %}

<!--
___ ___ ________ __ ___ __ ___ __ __ ______ __ __ _____ _______ __ __
Expand All @@ -66,7 +68,10 @@
{% include 'footer.njk' %}

<script src="{{ '/assets/javascripts/application.js' | url }}?v={{ site.builtAt }}" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>

{% if include_prism %}
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
{% endif %}
</body>
</html>
1 change: 1 addition & 0 deletions src/_layouts/post-coding.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
layout: base
include_prism: true
---

{% if codepen %}
Expand Down
1 change: 1 addition & 0 deletions src/_layouts/post.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
layout: base
include_prism: true
---

{% if cover %}
Expand Down

0 comments on commit 6208293

Please sign in to comment.