From 7233f99966ab1bfcfc6176780b79e8e9137d2fb9 Mon Sep 17 00:00:00 2001 From: Thomas Piart Date: Sat, 14 Dec 2019 09:09:56 +0100 Subject: [PATCH] Document setting variables --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 1d89a2b..6ca37f8 100644 --- a/README.md +++ b/README.md @@ -39,5 +39,35 @@ stylus: - **basePath** - Base path from which sourcemap and all sources are relative (default: `.`) - **plugins** - Stylus plugin(s) (default: `nib`) +## Setting Stylus variables + +It is possible to set variables that can be used in Stylus. +The purpose of setting variable is to avoid direct modification of the Sylus code, +and thus to make themes more generic + +For example, instead of hardcoding: +```stylus +div + color #FFCC44 +``` + +You can refer to a variable: +```stylus +div + color convert(hexo-config("color")) +``` + +And in your theme's configuration, you can define this variable: +```yml +color: "#FFCC44" +``` +(The "convert" function above is here to convert the string into an actual stylus color) + +You can also use the theme_config variable in the main `_config.yml`: +```yml +theme_config: + color: "#FFCC44" +``` + [Stylus]: http://stylus-lang.com/ [nib]: http://stylus.github.io/nib/