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

Document setting variables #41

Merged
merged 1 commit into from
Apr 25, 2020
Merged
Changes from all commits
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
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/