In order to facilitate the flexible and rich functional logic of the frontend, some environmental variables need to be injected into the frontend
Cabloy-CMS itself has some built-in environment variables. Meanwhile, you can also inject custom variables through env
of the backend context object
. These variables will be merged and then injected into the frontend
Inject env
env('index',{
[_path]:data.index,
});
Placeholder
_ _ENV_ _
Environment Object Structure
<script type="text/javascript">
var env={
"base": {
"title": "my blog",
"subTitle": "gone with the wind",
"description": "",
"keywords": ""
},
"language": {
"items": "en-us,zh-cn",
"default": "en-us",
"current": "en-us"
},
"format": {
"date": "YYYY-MM-DD",
"time": "HH:mm:ss"
},
"comment": {
"order": "asc",
"recentNum": 5
},
"site": {
"path": "main/article",
"serverUrl": "https://zhennann.cabloy.com",
"rawRootUrl": "https://zhennann.me"
},
"article": ...,
"index": {
"main/index/index": 20
}
};
</script>
Name | Provided by | Description |
---|---|---|
base | site configuration | site basic information |
language | site configuration | language information |
format | site configuration | date time formatting |
comment | site configuration | comment parameters |
site | built-in | site parameters |
site.path | path indication of current page | |
site.serverUrl | URL prefix of backend API | |
site.rawRootUrl | URL prefix of website root path | |
article | built-in | If the current rendering page is an article, this property is automatically injected |
index | theme, plugin or custom | for example, main/index/index is injected by the theme cms-themeblog |
Comments: