Giter Site home page Giter Site logo

Comments (3)

welpo avatar welpo commented on May 28, 2024 1

Hey @stevenroose and @Jieiku,

Thank you both for your suggestions and input on this issue!

I've implemented the feature to allow dynamic loading of extra stylesheets in #118. You can now specify additional stylesheets both in the config.toml file and in individual page metadata in the [extra] section of the front matter.

How to Use

  1. Site-wide: Add the stylesheet names to the stylesheets field in config.toml like this:

    [extra]
    stylesheets = ["extra1.css", "path/extra2.css"]
  2. Individual pages: Specify the additional stylesheets in the [extra] section in the front matter of the post like so:

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

Note: If you're working with .sass or .scss files, remember to specify the processed .css filenames, as Zola renders these into .css files in the public folder (docs). For example:

[extra]
stylesheets = ["extra.css"]  # Corresponding to `sass/extra.scss`

The feature has been documented in the config.toml and in the PR.

Have a fantastic weekend :)

from tabi.

Jieiku avatar Jieiku commented on May 28, 2024

stylesheets could be defined in config.toml like this:

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

You could then load any extra stylesheets via a loop.

  {%- set stylesheets=config.extra.stylesheets | default(value=[ "main.css" ]) -%}
  {%- if stylesheets %}{%- for i in stylesheets %}
  <link rel="stylesheet" href="{{ get_url(path=i, trailing_slash=false, cachebust=true) | safe }}" />
  {%- endfor %}{%- endif %}

from tabi.

welpo avatar welpo commented on May 28, 2024

Hey Steven!

Thanks for the feature request. Funnily enough, this was an undocumented feature until I removed it when adding skins (#105).

I'll bring it back! And better than ever.

Along with loading CSS files from config.toml, like Jieiku showed (thanks), I will allow loading files for individual posts as well, in the [extra] section of the post's front matter.

from tabi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.