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

Support inlining CSS for a performance boost. #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ show_tags = true
# ["orange", "blue", "red", "green", "pink"]
theme_color = "orange"

# Whether or not to inline CSS in the generated HTML. Can provide
# a performance improvement for some sites.
adworacz marked this conversation as resolved.
Show resolved Hide resolved
inline_css = false

# Custom css to style over the defaults. This is useful when you only have a
# few small tweaks to make rather than a major rehaul to the theme.
# It would be best to make this a proper .sass or .scss file in sass/ rather
Expand Down
19 changes: 13 additions & 6 deletions templates/macros/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
-#}

{% macro styling() %}
<link rel="stylesheet" href="{{ get_url(path="style.css") }}">
{% if config.extra.theme_color != "orange" -%}
{% set color = "color/" ~ config.extra.theme_color ~ ".css" -%}
<link rel="stylesheet" href="{{ get_url(path=color) }}">
{%- else -%}
<link rel="stylesheet" href=" {{ get_url(path="color/orange.css") }}">
{% if config.extra.inline_css -%}
{% set styleCSS = load_data(path="public/style.css", format="plain") -%}
<style>{{ styleCSS | trim | safe }}</style>
{% else %}
<link rel="stylesheet" href="{{ get_url(path="style.css") }}">
{% endif %}
{% set color = config.extra.theme_color | default(value="orange") -%}
{% set colorCSS = "color/" ~ color ~ ".css" -%}
{% if config.extra.inline_css -%}
{% set colorCSS = load_data(path="public/" ~ colorCSS, format="plain") -%}
<style>{{ colorCSS | trim | safe }}</style>
{% else -%}
<link rel="stylesheet" href="{{ get_url(path=colorCSS) }}">
{% endif %}
{%- if config.extra.custom_css is defined -%}
<link rel="stylesheet" href="{{ get_url(path="custom.css") }}">
Expand Down