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

✨feat(config): add dynamic stylesheet loading via config.toml and page Metadata #118

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

welpo
Copy link
Owner

@welpo welpo commented Aug 26, 2023

Description

This PR addresses issue #117. It adds a new feature that allows users to specify additional stylesheets in the config.toml and individual page metadata. This functionality adds flexibility for custom themes and individual post styling.

PR #105 removed a simpler (and undocumented) implementation of this feature.

Changes

  • Implemented dynamic stylesheet loading in the header.html template.
  • Added stylesheets field to config.toml and theme.toml.
  • Updated documentation in the configuration files to guide users on using the new feature.

How to use:

  1. Specify additional stylesheets in config.toml under stylesheets as an array. For a single file there's no need for an array.

    [extra]
    stylesheets = ["extra1.css", "path/extra2.css"]
  2. For individual pages, add stylesheets to the [extra] section in the front matter.

    +++
    title = "My Page"
    [extra]
    stylesheets = "individual.css"  # Use an array for more than one file.
    +++

Note: Since Zola processes .sass and .scss files in the sass folder into .css files in the public folder (see Zola docs), you should specify the processed .css filenames in the stylesheets field.

For example, if you have a .scss file located at sass/extra.scss, Zola will render it into public/extra.css. You should then specify extra.css in the stylesheets field like so:

[extra]
stylesheets = ["extra.css"]

Allow custom stylesheets loading on a site-wide or per-page basis.
@welpo welpo added the enhancement New feature or request label Aug 26, 2023
@welpo welpo merged commit fac730e into main Aug 26, 2023
1 check passed
@welpo welpo deleted the feat/load-extra-css branch August 26, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant