Skip to content

Commit

Permalink
Document setting variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tomap committed Dec 14, 2019
1 parent 76fd29a commit 7233f99
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/

0 comments on commit 7233f99

Please sign in to comment.