Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for strict CSP policy #96

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

celeroncool
Copy link

Hello,

I use this theme for my site https://nenimein.fi/blog, and it wasnt working correctly because some of the CSS and JS are loaded inline.

In this PR, I have converted those inline scripts to external CSS and JS files to make the theme compatible with Content-Security-Policy default-src 'self';

For highlighting I followed these instructions https://sean.burlington.me.uk/post/hugo-syntax-highlight-unsafe-inline.html.
And for JS, I just converted the inline script to external JS, and created hash for it with openssl.

Needs to be its own JS file to be compatible with CSP policy "self"
Add css/syntax.css for monokai markdown highlight compatible with strict CSP policy.
Move darkmode preference toggle to own JS file so it is compatible with strict CSP policy.
Created using hugo gen chromastyles --style=monokai > syntax.css
Add default markup as monokai and set syntax highlight to external CSS file.
Make theme compatible with strict CSP policy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant