Skip to content

Commit

Permalink
fix: tocOptions and csp interop
Browse files Browse the repository at this point in the history
  • Loading branch information
TrebledJ committed Sep 22, 2024
1 parent 83a484e commit 974b380
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ tags:
- linux
- windows
thumbnail_src: assets/attack-of-the-zip-thumbnail.jpg
tocOptions: '{"tags":["h2","h3","h4"]}'
tocOptions:
tags: [h2, h3, h4]
preamble: |
*Last month, I designed a CTF challenge involving zip file attacks. This post is a collection of the techniques, insights, and notes I've gathered. I've also uploaded the challenge on [GitHub](https://github.com/TrebledJ/attack-of-the-zip) along with a simplified playground.*
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ tags:
- writeup
thumbnail_src: assets/drogon-thumbnail.png
thumbnail_banner: true
tocOptions: '{"tags":["h2","h3","h4"]}'
tocOptions:
tags: [h2, h3, h4]
related:
posts: [attack-of-the-zip]
# preamble: |
Expand Down
6 changes: 5 additions & 1 deletion eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ module.exports = function (eleventyConfig) {
return content;
});

eleventyConfig.addTransform('htmlcsp', htmlcsp);
// Indirect: wrap addTransform with addPlugin, so that bundled inline JS
// gets substituted before calling htmlcsp.
eleventyConfig.addPlugin(function (eleventyConfig) {
eleventyConfig.addTransform('htmlcsp', htmlcsp);
});
}

// Customize Markdown library settings:
Expand Down
4 changes: 2 additions & 2 deletions eleventy/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginNavigation);

eleventyConfig.addPlugin(pluginBundle, {
bundles: ['inlinecss'],
bundles: ['inlinecss', 'inlinejs'],
toFileDirectory: 'cb',
transforms: [
async function (content) {
Expand All @@ -38,7 +38,7 @@ module.exports = function (eleventyConfig) {
return output.styles;
}

if (this.type === 'js') {
if (this.type === 'js' || this.type === 'inlinejs') {
const result = await minify(content);
return result.code;
}
Expand Down
9 changes: 8 additions & 1 deletion partials/_includes/utilities/bundle-js.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{# Bundle JS. #}
{% js %}

{# Some variables are per-post. For instance, some posts have different ToC options. #}
{% inlinejs %}
var tocOptions = {{ tocOptions | default({}) | dump | safe }};
{% endinlinejs %}

{% js %}
var site = {
typewrite: {{ site.typewrite | dump | safe }},
search: {{ site.search | dump | safe }},
Expand Down Expand Up @@ -55,4 +60,6 @@
{% set jsBundle %}
{%- getBundleFileUrl "js" -%}
{% endset %}

<script>{% getBundle "inlinejs" %}</script>
<script defer src="{{jsBundle}}"></script>

0 comments on commit 974b380

Please sign in to comment.