--- title: 页面变量 description: 每个页面所返回的变量 --- ## 首页(index.ftl) 访问路径:`http://yourdomain` ### posts(List) #### 语法 ```html <#list posts.content as post> // do something #list> ``` #### 参数 ```json [{ "content": [{ "categories": [{ "createTime": "2020-10-13T13:23:39.143Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "slug": "string", "thumbnail": "string" }], "commentCount": 0, "createTime": "2020-10-13T13:23:39.143Z", "disallowComment": true, "editTime": "2020-10-13T13:23:39.143Z", "editorType": "MARKDOWN", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaKeywords": "string", "metas": {}, "password": "string", "slug": "string", "status": "PUBLISHED", "summary": "string", "tags": [{ "createTime": "2020-10-13T13:23:39.143Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" }], "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2020-10-13T13:23:39.143Z", "visits": 0, "wordCount": 0 }], "empty": true, "first": true, "last": true, "number": 0, "numberOfElements": 0, "pageable": { "page": 0, "size": 0, "sort": [ "string" ] }, "size": 0, "sort": { "sort": [ "string" ] }, "totalElements": 0, "totalPages": 0 }] ``` #### 示例 遍历输出首页的文章: ```html <#list posts.content as post> ${post.title!} #list> ``` 输出: ```html title1 title2 title3 ``` ## 文章页面(post.ftl) 访问路径不固定,视固定链接配置而定,目前可以配置的有: - `http://yourdomain/archives/{slug}`(默认) - `http://yourdomain/1970/01/{slug}` - `http://yourdomain/1970/01/01/{slug}` - `http://yourdomain/?p={id}` - `http://yourdomain/archives/{id}` ### post(Object) #### 语法 ```html ${post.attribute} ``` 注:attribute 代表具体属性。 #### 参数 ```json { "categories": [ { "createTime": "2021-02-25T13:15:58.589Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "password": "string", "slug": "string", "thumbnail": "string" } ], "categoryIds": [ 0 ], "commentCount": 0, "createTime": "2021-02-25T13:15:58.589Z", "disallowComment": true, "editTime": "2021-02-25T13:15:58.589Z", "editorType": "MARKDOWN", "formatContent": "string", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaIds": [ 0 ], "metaKeywords": "string", "metas": [ { "createTime": "2021-02-25T13:15:58.589Z", "id": 0, "key": "string", "postId": 0, "value": "string" } ], "originalContent": "string", "password": "string", "slug": "string", "status": "DRAFT", "summary": "string", "tagIds": [ 0 ], "tags": [ { "createTime": "2021-02-25T13:15:58.589Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" } ], "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2021-02-25T13:15:58.589Z", "visits": 0, "wordCount": 0 } ``` #### 示例 获取文章标题: ```html ${post.title!} ``` 输出: ```html 示例文章 ``` ### prevPost(Object) #### 语法 ```html ${prevPost.attribute} ``` 注:attribute 代表具体属性。 #### 参数 ```json { "categories": [ { "createTime": "2021-02-25T13:15:58.589Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "password": "string", "slug": "string", "thumbnail": "string" } ], "categoryIds": [ 0 ], "commentCount": 0, "createTime": "2021-02-25T13:15:58.589Z", "disallowComment": true, "editTime": "2021-02-25T13:15:58.589Z", "editorType": "MARKDOWN", "formatContent": "string", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaIds": [ 0 ], "metaKeywords": "string", "metas": [ { "createTime": "2021-02-25T13:15:58.589Z", "id": 0, "key": "string", "postId": 0, "value": "string" } ], "originalContent": "string", "password": "string", "slug": "string", "status": "DRAFT", "summary": "string", "tagIds": [ 0 ], "tags": [ { "createTime": "2021-02-25T13:15:58.589Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" } ], "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2021-02-25T13:15:58.589Z", "visits": 0, "wordCount": 0 } ``` #### 示例 获取上一篇文章的信息: ```html <#if prevPost??> 上一篇:${prevPost.title!} #if> ``` 输出: ```html 上一篇:title1 ``` ### nextPost(Object) #### 语法 ```html ${nextPost.attribute} ``` 注:attribute 代表具体属性。 #### 参数 ```json { "categories": [ { "createTime": "2021-02-25T13:15:58.589Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "password": "string", "slug": "string", "thumbnail": "string" } ], "categoryIds": [ 0 ], "commentCount": 0, "createTime": "2021-02-25T13:15:58.589Z", "disallowComment": true, "editTime": "2021-02-25T13:15:58.589Z", "editorType": "MARKDOWN", "formatContent": "string", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaIds": [ 0 ], "metaKeywords": "string", "metas": [ { "createTime": "2021-02-25T13:15:58.589Z", "id": 0, "key": "string", "postId": 0, "value": "string" } ], "originalContent": "string", "password": "string", "slug": "string", "status": "DRAFT", "summary": "string", "tagIds": [ 0 ], "tags": [ { "createTime": "2021-02-25T13:15:58.589Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" } ], "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2021-02-25T13:15:58.589Z", "visits": 0, "wordCount": 0 } ``` #### 示例 获取下一篇文章的信息: ```html <#if nextPost??> 上一篇:${nextPost.title!} #if> ``` 输出: ```html 上一篇:title3 ``` ### categories(List) #### 语法 ```html <#list categories as category> // do something #list> ``` #### 参数 ```json [{ "createTime": "2021-02-25T13:32:11.189Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "password": "string", "slug": "string", "thumbnail": "string" }] ``` #### 示例 获取文章的分类列表: ```html <#list categories as category> ${category.name!} #list> ``` 输出: ```html name1 name2 ``` ### tags(List) #### 语法 ```html <#list tags as tag> // do something #list> ``` #### 参数 ```json [{ "createTime": "2021-02-25T13:34:48.779Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" }] ``` #### 示例 获取文章的标签列表: ```html <#list tags as tag> ${tag.name!} #list> ``` 输出: ```html name1 name2 ``` ### metas(Object) #### 语法 ```html ${metas.key} ``` 注:attribute 代表具体 key 值。 #### 参数 无 #### 示例 获取用户设置的音乐链接: ```html ``` 输出: ```html ``` ## 自定义页面(sheet.ftl) 访问路径不固定,视固定链接配置而定,默认为:`http://yourdomain/s/{slug}` ### sheet(Object) #### 语法 ```html ${sheet.attribute} ``` 注:attribute 代表具体属性。 #### 参数 ```json { "commentCount": 0, "createTime": "2021-02-25T13:37:29.775Z", "disallowComment": true, "editTime": "2021-02-25T13:37:29.775Z", "editorType": "MARKDOWN", "formatContent": "string", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaIds": [ 0 ], "metaKeywords": "string", "metas": [ { "createTime": "2021-02-25T13:37:29.775Z", "id": 0, "key": "string", "postId": 0, "value": "string" } ], "originalContent": "string", "password": "string", "slug": "string", "status": "DRAFT", "summary": "string", "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2021-02-25T13:37:29.775Z", "visits": 0, "wordCount": 0 } ``` #### 示例 获取页面标题: ```html ${sheet.title!} ``` 输出: ```html 示例页面 ``` ### metas(Object) #### 语法 ```html ${metas.key} ``` 注:attribute 代表具体 key 值。 #### 参数 无 #### 示例 获取用户设置的音乐链接: ```html ``` 输出: ```html ``` ## 文章归档页面(archives.ftl) 访问路径不固定,视固定链接配置而定,默认为:`http://yourdomain/archives` ### posts(List) #### 语法 ```html <#list posts.content as post> // do something #list> ``` #### 参数 ```json [{ "content": [{ "categories": [{ "createTime": "2020-10-13T13:23:39.143Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "slug": "string", "thumbnail": "string" }], "commentCount": 0, "createTime": "2020-10-13T13:23:39.143Z", "disallowComment": true, "editTime": "2020-10-13T13:23:39.143Z", "editorType": "MARKDOWN", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaKeywords": "string", "metas": {}, "password": "string", "slug": "string", "status": "PUBLISHED", "summary": "string", "tags": [{ "createTime": "2020-10-13T13:23:39.143Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" }], "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2020-10-13T13:23:39.143Z", "visits": 0, "wordCount": 0 }], "empty": true, "first": true, "last": true, "number": 0, "numberOfElements": 0, "pageable": { "page": 0, "size": 0, "sort": [ "string" ] }, "size": 0, "sort": { "sort": [ "string" ] }, "totalElements": 0, "totalPages": 0 }] ``` #### 示例 遍历输出归档页面的文章(无年份分组): ```html <#list posts.content as post> ${post.title!} #list> ``` 输出: ```html title1 title2 title3 ``` ### archives(List) #### 语法 ```html <#list archives.content as archive> // do something #list> ``` #### 参数 ```json { "content": [{ "posts": [{ "categories": [{ "createTime": "2021-03-07T05:45:06.271Z", "description": "string", "fullPath": "string", "id": 0, "name": "string", "parentId": 0, "password": "string", "slug": "string", "thumbnail": "string" }], "commentCount": 0, "createTime": "2021-03-07T05:45:06.271Z", "disallowComment": true, "editTime": "2021-03-07T05:45:06.271Z", "editorType": "MARKDOWN", "fullPath": "string", "id": 0, "likes": 0, "metaDescription": "string", "metaKeywords": "string", "metas": {}, "password": "string", "slug": "string", "status": "DRAFT", "summary": "string", "tags": [{ "createTime": "2021-03-07T05:45:06.271Z", "fullPath": "string", "id": 0, "name": "string", "slug": "string", "thumbnail": "string" }], "template": "string", "thumbnail": "string", "title": "string", "topPriority": 0, "topped": true, "updateTime": "2021-03-07T05:45:06.271Z", "visits": 0, "wordCount": 0 }], "year": 0 }], "hasContent": true, "hasNext": true, "hasPrevious": true, "isEmpty": true, "isFirst": true, "page": 0, "pages": 0, "rpp": 0, "total": 0 } ``` #### 示例 遍历输出归档页面的文章(有年份分组): ```html <#list archives.content as archive>