title: 模板标签

description: 用于获取数据的模板标签

:::note 模板标签可以运用在页面的任何地方。 :::

文章(postTag)

获取最新文章(latest)

语法

  1. <@postTag method="latest" top="获取条数">
  2. // do something
  3. </@postTag>

参数:

  1. method:latest
  2. top:所需要获取的条数

返回参数

posts:

  1. [{
  2. "categories": [{
  3. "createTime": "2020-10-11T05:22:08.264Z",
  4. "description": "string",
  5. "fullPath": "string",
  6. "id": 0,
  7. "name": "string",
  8. "parentId": 0,
  9. "slug": "string",
  10. "thumbnail": "string"
  11. }],
  12. "commentCount": 0,
  13. "createTime": "2020-10-11T05:22:08.264Z",
  14. "disallowComment": true,
  15. "editTime": "2020-10-11T05:22:08.264Z",
  16. "editorType": "MARKDOWN",
  17. "fullPath": "string",
  18. "id": 0,
  19. "likes": 0,
  20. "metaDescription": "string",
  21. "metaKeywords": "string",
  22. "metas": {},
  23. "password": "string",
  24. "slug": "string",
  25. "status": "PUBLISHED",
  26. "summary": "string",
  27. "tags": [{
  28. "createTime": "2020-10-11T05:22:08.264Z",
  29. "fullPath": "string",
  30. "id": 0,
  31. "name": "string",
  32. "slug": "string",
  33. "thumbnail": "string"
  34. }],
  35. "template": "string",
  36. "thumbnail": "string",
  37. "title": "string",
  38. "topPriority": 0,
  39. "topped": true,
  40. "updateTime": "2020-10-11T05:22:08.264Z",
  41. "visits": 0,
  42. "wordCount": 0
  43. }]

示例

  1. <@postTag method="latest" top="3">
  2. <#list posts as post>
  3. <a href="${post.fullPath!}">${post.title!}</a>
  4. </#list>
  5. </@postTag>

输出:

  1. <a href="http://localhost:8090/archives/url1">title1</a>
  2. <a href="http://localhost:8090/archives/url2">title2</a>
  3. <a href="http://localhost:8090/archives/url3">title3</a>

获取所有文章的数量(count)

语法

  1. <@postTag method="count">
  2. // do something
  3. </@postTag>

参数:

  1. method:count

返回参数

  1. count: long

示例

  1. <@postTag method="count">
  2. <span>文章数量:${count!0}</span>
  3. </@postTag>

输出:

  1. <span>文章数量:20</span>

根据年份归档(archiveYear)

语法

  1. <@postTag method="archiveYear">
  2. // do something
  3. </@postTag>

参数:

  1. method:archiveYear

返回参数

archives:

  1. [{
  2. "posts": [{
  3. "categories": [{
  4. "createTime": "2020-10-11T05:30:45.245Z",
  5. "description": "string",
  6. "fullPath": "string",
  7. "id": 0,
  8. "name": "string",
  9. "parentId": 0,
  10. "slug": "string",
  11. "thumbnail": "string"
  12. }],
  13. "commentCount": 0,
  14. "createTime": "2020-10-11T05:30:45.245Z",
  15. "disallowComment": true,
  16. "editTime": "2020-10-11T05:30:45.245Z",
  17. "editorType": "MARKDOWN",
  18. "fullPath": "string",
  19. "id": 0,
  20. "likes": 0,
  21. "metaDescription": "string",
  22. "metaKeywords": "string",
  23. "metas": {},
  24. "password": "string",
  25. "slug": "string",
  26. "status": "PUBLISHED",
  27. "summary": "string",
  28. "tags": [{
  29. "createTime": "2020-10-11T05:30:45.245Z",
  30. "fullPath": "string",
  31. "id": 0,
  32. "name": "string",
  33. "slug": "string",
  34. "thumbnail": "string"
  35. }],
  36. "template": "string",
  37. "thumbnail": "string",
  38. "title": "string",
  39. "topPriority": 0,
  40. "topped": true,
  41. "updateTime": "2020-10-11T05:30:45.245Z",
  42. "visits": 0,
  43. "wordCount": 0
  44. }],
  45. "year": 0
  46. }]

示例

  1. <@postTag method="archiveYear">
  2. <#list archives as archive>
  3. <h1>年份: ${archive.year?c}</h1>
  4. <ul>
  5. <#list archive.posts?sort_by("createTime")?reverse as post>
  6. <li>
  7. <a href="${post.fullPath!}">${post.title!}</a>
  8. </li>
  9. </#list>
  10. </ul>
  11. </#list>
  12. </@postTag>

输出:

  1. <h1>2019</h1>
  2. <ul>
  3. <li>
  4. <a href="http://localhost:8090/archives/url1">title1</a>
  5. </li>
  6. <li>
  7. <a href="http://localhost:8090/archives/url2">title2</a>
  8. </li>
  9. </ul>
  10. <h1>2018</h1>
  11. <ul>
  12. <li>
  13. <a href="http://localhost:8090/archives/url3">title3</a>
  14. </li>
  15. <li>
  16. <a href="http://localhost:8090/archives/url4">title4</a>
  17. </li>
  18. </ul>

根据年月归档(archiveMonth)

语法

  1. <@postTag method="archiveMonth">
  2. // do something
  3. </@postTag>

参数:

  1. method:archiveMonth

返回参数

archives:

  1. [{
  2. "month": 0,
  3. "posts": [{
  4. "categories": [{
  5. "createTime": "2020-10-11T05:35:01.835Z",
  6. "description": "string",
  7. "fullPath": "string",
  8. "id": 0,
  9. "name": "string",
  10. "parentId": 0,
  11. "slug": "string",
  12. "thumbnail": "string"
  13. }],
  14. "commentCount": 0,
  15. "createTime": "2020-10-11T05:35:01.835Z",
  16. "disallowComment": true,
  17. "editTime": "2020-10-11T05:35:01.835Z",
  18. "editorType": "MARKDOWN",
  19. "fullPath": "string",
  20. "id": 0,
  21. "likes": 0,
  22. "metaDescription": "string",
  23. "metaKeywords": "string",
  24. "metas": {},
  25. "password": "string",
  26. "slug": "string",
  27. "status": "PUBLISHED",
  28. "summary": "string",
  29. "tags": [{
  30. "createTime": "2020-10-11T05:35:01.835Z",
  31. "fullPath": "string",
  32. "id": 0,
  33. "name": "string",
  34. "slug": "string",
  35. "thumbnail": "string"
  36. }],
  37. "template": "string",
  38. "thumbnail": "string",
  39. "title": "string",
  40. "topPriority": 0,
  41. "topped": true,
  42. "updateTime": "2020-10-11T05:35:01.835Z",
  43. "visits": 0,
  44. "wordCount": 0
  45. }],
  46. "year": 0
  47. }]

示例

  1. <@postTag method="archiveMonth">
  2. <#list archives as archive>
  3. <h1>${archive.year?c}-${archive.month?c}</h1>
  4. <ul>
  5. <#list archive.posts?sort_by("createTime")?reverse as post>
  6. <li>
  7. <a href="${post.fullPath!}">${post.title!}</a>
  8. </li>
  9. </#list>
  10. </ul>
  11. </#list>
  12. </@postTag>

输出:

  1. <h1>2019-01</h1>
  2. <ul>
  3. <li>
  4. <a href="http://localhost:8090/archives/url1">title1</a>
  5. </li>
  6. <li>
  7. <a href="http://localhost:8090/archives/url2">title2</a>
  8. </li>
  9. </ul>
  10. <h1>2018-12</h1>
  11. <ul>
  12. <li>
  13. <a href="http://localhost:8090/archives/url3">title3</a>
  14. </li>
  15. <li>
  16. <a href="http://localhost:8090/archives/url3">title4</a>
  17. </li>
  18. </ul>

归档(archive)

语法

  1. <@postTag method="archive" type="year or month">
  2. // do something
  3. </@postTag>

参数:

  1. method:archive
  2. type: year 或者 month

返回参数

archives(year):

  1. [{
  2. "posts": [{
  3. "categories": [{
  4. "createTime": "2020-10-11T05:30:45.245Z",
  5. "description": "string",
  6. "fullPath": "string",
  7. "id": 0,
  8. "name": "string",
  9. "parentId": 0,
  10. "slug": "string",
  11. "thumbnail": "string"
  12. }],
  13. "commentCount": 0,
  14. "createTime": "2020-10-11T05:30:45.245Z",
  15. "disallowComment": true,
  16. "editTime": "2020-10-11T05:30:45.245Z",
  17. "editorType": "MARKDOWN",
  18. "fullPath": "string",
  19. "id": 0,
  20. "likes": 0,
  21. "metaDescription": "string",
  22. "metaKeywords": "string",
  23. "metas": {},
  24. "password": "string",
  25. "slug": "string",
  26. "status": "PUBLISHED",
  27. "summary": "string",
  28. "tags": [{
  29. "createTime": "2020-10-11T05:30:45.245Z",
  30. "fullPath": "string",
  31. "id": 0,
  32. "name": "string",
  33. "slug": "string",
  34. "thumbnail": "string"
  35. }],
  36. "template": "string",
  37. "thumbnail": "string",
  38. "title": "string",
  39. "topPriority": 0,
  40. "topped": true,
  41. "updateTime": "2020-10-11T05:30:45.245Z",
  42. "visits": 0,
  43. "wordCount": 0
  44. }],
  45. "year": 0
  46. }]

archives(month):

  1. [{
  2. "month": 0,
  3. "posts": [{
  4. "categories": [{
  5. "createTime": "2020-10-11T05:35:01.835Z",
  6. "description": "string",
  7. "fullPath": "string",
  8. "id": 0,
  9. "name": "string",
  10. "parentId": 0,
  11. "slug": "string",
  12. "thumbnail": "string"
  13. }],
  14. "commentCount": 0,
  15. "createTime": "2020-10-11T05:35:01.835Z",
  16. "disallowComment": true,
  17. "editTime": "2020-10-11T05:35:01.835Z",
  18. "editorType": "MARKDOWN",
  19. "fullPath": "string",
  20. "id": 0,
  21. "likes": 0,
  22. "metaDescription": "string",
  23. "metaKeywords": "string",
  24. "metas": {},
  25. "password": "string",
  26. "slug": "string",
  27. "status": "PUBLISHED",
  28. "summary": "string",
  29. "tags": [{
  30. "createTime": "2020-10-11T05:35:01.835Z",
  31. "fullPath": "string",
  32. "id": 0,
  33. "name": "string",
  34. "slug": "string",
  35. "thumbnail": "string"
  36. }],
  37. "template": "string",
  38. "thumbnail": "string",
  39. "title": "string",
  40. "topPriority": 0,
  41. "topped": true,
  42. "updateTime": "2020-10-11T05:35:01.835Z",
  43. "visits": 0,
  44. "wordCount": 0
  45. }],
  46. "year": 0
  47. }]

示例

  1. <@postTag method="archive" type="month">
  2. <#list archives as archive>
  3. <h1>${archive.year?c}-${archive.month?c}</h1>
  4. <ul>
  5. <#list archive.posts?sort_by("createTime")?reverse as post>
  6. <li>
  7. <a href="${post.fullPath!}">${post.title!}</a>
  8. </li>
  9. </#list>
  10. </ul>
  11. </#list>
  12. </@postTag>

输出:

  1. <h1>2019-01</h1>
  2. <ul>
  3. <li>
  4. <a href="http://localhost:8090/archives/url1">title1</a>
  5. </li>
  6. <li>
  7. <a href="http://localhost:8090/archives/url2">title2</a>
  8. </li>
  9. </ul>
  10. <h1>2018-12</h1>
  11. <ul>
  12. <li>
  13. <a href="http://localhost:8090/archives/url3">title3</a>
  14. </li>
  15. <li>
  16. <a href="http://localhost:8090/archives/url3">title4</a>
  17. </li>
  18. </ul>

根据分类 id 获取文章(listByCategoryId)

语法

  1. <@postTag method="listByCategoryId" categoryId="分类 id">
  2. // do something
  3. </@postTag>

参数:

  1. method:listByCategoryId
  2. categoryId:分类 id

返回参数

posts:

  1. [{
  2. "categories": [{
  3. "createTime": "2020-10-11T05:35:01.811Z",
  4. "description": "string",
  5. "fullPath": "string",
  6. "id": 0,
  7. "name": "string",
  8. "parentId": 0,
  9. "slug": "string",
  10. "thumbnail": "string"
  11. }],
  12. "commentCount": 0,
  13. "createTime": "2020-10-11T05:35:01.811Z",
  14. "disallowComment": true,
  15. "editTime": "2020-10-11T05:35:01.811Z",
  16. "editorType": "MARKDOWN",
  17. "fullPath": "string",
  18. "id": 0,
  19. "likes": 0,
  20. "metaDescription": "string",
  21. "metaKeywords": "string",
  22. "metas": {},
  23. "password": "string",
  24. "slug": "string",
  25. "status": "PUBLISHED",
  26. "summary": "string",
  27. "tags": [{
  28. "createTime": "2020-10-11T05:35:01.811Z",
  29. "fullPath": "string",
  30. "id": 0,
  31. "name": "string",
  32. "slug": "string",
  33. "thumbnail": "string"
  34. }],
  35. "template": "string",
  36. "thumbnail": "string",
  37. "title": "string",
  38. "topPriority": 0,
  39. "topped": true,
  40. "updateTime": "2020-10-11T05:35:01.811Z",
  41. "visits": 0,
  42. "wordCount": 0
  43. }]

示例

  1. <@postTag method="listByCategoryId" top="${category.id?c}">
  2. <span>分类 ${category.name!} 下的文章:</span>
  3. <#list posts as post>
  4. <a href="${post.fullPath!}">${post.title!}</a>
  5. </#list>
  6. </@postTag>

输出:

  1. <a href="http://localhost:8090/archives/url1">title1</a>
  2. <a href="http://localhost:8090/archives/url2">title2</a>
  3. <a href="http://localhost:8090/archives/url3">title3</a>

根据分类 slug 获取文章(listByCategorySlug)

语法

  1. <@postTag method="listByCategorySlug" categorySlug="分类 slug">
  2. // do something
  3. </@postTag>

参数:

  1. method:listByCategorySlug
  2. categorySlug:分类 slug

返回参数

posts:

  1. [{
  2. "categories": [{
  3. "createTime": "2020-10-11T05:35:01.811Z",
  4. "description": "string",
  5. "fullPath": "string",
  6. "id": 0,
  7. "name": "string",
  8. "parentId": 0,
  9. "slug": "string",
  10. "thumbnail": "string"
  11. }],
  12. "commentCount": 0,
  13. "createTime": "2020-10-11T05:35:01.811Z",
  14. "disallowComment": true,
  15. "editTime": "2020-10-11T05:35:01.811Z",
  16. "editorType": "MARKDOWN",
  17. "fullPath": "string",
  18. "id": 0,
  19. "likes": 0,
  20. "metaDescription": "string",
  21. "metaKeywords": "string",
  22. "metas": {},
  23. "password": "string",
  24. "slug": "string",
  25. "status": "PUBLISHED",
  26. "summary": "string",
  27. "tags": [{
  28. "createTime": "2020-10-11T05:35:01.811Z",
  29. "fullPath": "string",
  30. "id": 0,
  31. "name": "string",
  32. "slug": "string",
  33. "thumbnail": "string"
  34. }],
  35. "template": "string",
  36. "thumbnail": "string",
  37. "title": "string",
  38. "topPriority": 0,
  39. "topped": true,
  40. "updateTime": "2020-10-11T05:35:01.811Z",
  41. "visits": 0,
  42. "wordCount": 0
  43. }]

示例

  1. <@postTag method="listByCategorySlug" categorySlug="${category.slug!}">
  2. <span>分类 ${category.name!} 下的文章:</span>
  3. <#list posts as post>
  4. <a href="${post.fullPath!}">${post.title!}</a>
  5. </#list>
  6. </@postTag>

输出:

  1. <a href="http://localhost:8090/archives/url1">title1</a>
  2. <a href="http://localhost:8090/archives/url2">title2</a>
  3. <a href="http://localhost:8090/archives/url3">title3</a>

根据标签 id 获取文章(listByTagId)

语法

  1. <@postTag method="listByTagId" tagId="标签 id">
  2. // do something
  3. </@postTag>

参数:

  1. method:listByTagId
  2. tagId:标签 id

返回参数

posts:

  1. [{
  2. "categories": [{
  3. "createTime": "2020-10-11T05:35:01.811Z",
  4. "description": "string",
  5. "fullPath": "string",
  6. "id": 0,
  7. "name": "string",
  8. "parentId": 0,
  9. "slug": "string",
  10. "thumbnail": "string"
  11. }],
  12. "commentCount": 0,
  13. "createTime": "2020-10-11T05:35:01.811Z",
  14. "disallowComment": true,
  15. "editTime": "2020-10-11T05:35:01.811Z",
  16. "editorType": "MARKDOWN",
  17. "fullPath": "string",
  18. "id": 0,
  19. "likes": 0,
  20. "metaDescription": "string",
  21. "metaKeywords": "string",
  22. "metas": {},
  23. "password": "string",
  24. "slug": "string",
  25. "status": "PUBLISHED",
  26. "summary": "string",
  27. "tags": [{
  28. "createTime": "2020-10-11T05:35:01.811Z",
  29. "fullPath": "string",
  30. "id": 0,
  31. "name": "string",
  32. "slug": "string",
  33. "thumbnail": "string"
  34. }],
  35. "template": "string",
  36. "thumbnail": "string",
  37. "title": "string",
  38. "topPriority": 0,
  39. "topped": true,
  40. "updateTime": "2020-10-11T05:35:01.811Z",
  41. "visits": 0,
  42. "wordCount": 0
  43. }]

示例

  1. <@postTag method="listByTagId" tagId="${tag.id?c}">
  2. <span>标签 ${tag.name!} 下的文章:</span>
  3. <#list posts as post>
  4. <a href="${post.fullPath!}">${post.title!}</a>
  5. </#list>
  6. </@postTag>

输出:

  1. <a href="http://localhost:8090/archives/url1">title1</a>
  2. <a href="http://localhost:8090/archives/url2">title2</a>
  3. <a href="http://localhost:8090/archives/url3">title3</a>

根据标签 slug 获取文章(listByTagSlug)

语法

  1. <@postTag method="listByTagSlug" tagSlug="标签 slug">
  2. // do something
  3. </@postTag>

参数:

  1. method:listByTagSlug
  2. tagSlug:标签 slug

返回参数

posts:

  1. [{
  2. "categories": [{
  3. "createTime": "2020-10-11T05:35:01.811Z",
  4. "description": "string",
  5. "fullPath": "string",
  6. "id": 0,
  7. "name": "string",
  8. "parentId": 0,
  9. "slug": "string",
  10. "thumbnail": "string"
  11. }],
  12. "commentCount": 0,
  13. "createTime": "2020-10-11T05:35:01.811Z",
  14. "disallowComment": true,
  15. "editTime": "2020-10-11T05:35:01.811Z",
  16. "editorType": "MARKDOWN",
  17. "fullPath": "string",
  18. "id": 0,
  19. "likes": 0,
  20. "metaDescription": "string",
  21. "metaKeywords": "string",
  22. "metas": {},
  23. "password": "string",
  24. "slug": "string",
  25. "status": "PUBLISHED",
  26. "summary": "string",
  27. "tags": [{
  28. "createTime": "2020-10-11T05:35:01.811Z",
  29. "fullPath": "string",
  30. "id": 0,
  31. "name": "string",
  32. "slug": "string",
  33. "thumbnail": "string"
  34. }],
  35. "template": "string",
  36. "thumbnail": "string",
  37. "title": "string",
  38. "topPriority": 0,
  39. "topped": true,
  40. "updateTime": "2020-10-11T05:35:01.811Z",
  41. "visits": 0,
  42. "wordCount": 0
  43. }]

示例

  1. <@postTag method="listByTagSlug" tagSlug="${tag.slug!}">
  2. <span>标签 ${tag.name!} 下的文章:</span>
  3. <#list posts as post>
  4. <a href="${post.fullPath!}">${post.title!}</a>
  5. </#list>
  6. </@postTag>

输出:

  1. <a href="http://localhost:8090/archives/url1">title1</a>
  2. <a href="http://localhost:8090/archives/url2">title2</a>
  3. <a href="http://localhost:8090/archives/url3">title3</a>

评论(commentTag)

获取最新评论(latest)

语法

  1. <@commentTag method="latest" top="获取条数">
  2. // do something
  3. </@commentTag>

参数:

  1. method:latest
  2. top:所需要获取的条数

返回参数

comments:

  1. [{
  2. "allowNotification": true,
  3. "author": "string",
  4. "authorUrl": "string",
  5. "content": "string",
  6. "createTime": "2020-10-13T12:35:54.974Z",
  7. "email": "string",
  8. "gravatarMd5": "string",
  9. "id": 0,
  10. "ipAddress": "string",
  11. "isAdmin": true,
  12. "parentId": 0,
  13. "post": {
  14. "createTime": "2020-10-13T12:35:54.974Z",
  15. "editTime": "2020-10-13T12:35:54.974Z",
  16. "editorType": "MARKDOWN",
  17. "fullPath": "string",
  18. "id": 0,
  19. "metaDescription": "string",
  20. "metaKeywords": "string",
  21. "slug": "string",
  22. "status": "PUBLISHED",
  23. "title": "string",
  24. "updateTime": "2020-10-13T12:35:54.974Z"
  25. },
  26. "status": "PUBLISHED",
  27. "userAgent": "string"
  28. }]

示例

  1. <@commentTag method="latest" top="获取条数">
  2. <ul>
  3. <#list comments.content as comment>
  4. <li>${comment.author!}:${comment.content!}</li>
  5. </#list>
  6. </ul>
  7. </@commentTag>

输出:

  1. <ul>
  2. <li>author1:content1</li>
  3. <li>author2:content2</li>
  4. </ul>

获取所有评论的数量(count)

语法

  1. <@commentTag method="count">
  2. // do something
  3. </@commentTag>

参数:

  1. method:count

返回参数

  1. count: long

示例

  1. <@commentTag method="count">
  2. <span>评论数量:${count!0}</span>
  3. </@commentTag>

输出:

  1. <span>文章数量:20</span>

分类目录(categoryTag)

获取所有分类目录(list)

语法

  1. <@categoryTag method="list">
  2. // do something
  3. </@categoryTag>

参数:

  1. method:list

返回参数

categories:

  1. [{
  2. "createTime": "2020-10-11T05:59:40.622Z",
  3. "description": "string",
  4. "fullPath": "string",
  5. "id": 0,
  6. "name": "string",
  7. "parentId": 0,
  8. "slug": "string",
  9. "thumbnail": "string",
  10. "postCount": 0
  11. }]

示例

  1. <@categoryTag method="list">
  2. <#list categories as category>
  3. <a href="${category.fullPath!}">${category.name!}(${category.postCount!})</a>
  4. </#list>
  5. </@categoryTag>

输出:

  1. <a href="http://localhost:8090/categories/url1">name1(2)</a>
  2. <a href="http://localhost:8090/categories/url2">name2(12)</a>

获取分类目录树结构(tree)

语法

  1. <@categoryTag method="tree">
  2. // do something
  3. </@categoryTag>

参数:

  1. method:tree

返回参数

categories:

  1. [
  2. {
  3. "children": [
  4. {
  5. "children": [],
  6. "createTime": "2022-02-12T14:11:06.376Z",
  7. "description": "string",
  8. "fullPath": "string",
  9. "id": 0,
  10. "name": "string",
  11. "parentId": 0,
  12. "password": "string",
  13. "slug": "string",
  14. "thumbnail": "string"
  15. }
  16. ],
  17. "createTime": "2022-02-12T14:11:06.376Z",
  18. "description": "string",
  19. "fullPath": "string",
  20. "id": 0,
  21. "name": "string",
  22. "parentId": 0,
  23. "password": "string",
  24. "slug": "string",
  25. "thumbnail": "string"
  26. }
  27. ]

示例

  1. <@categoryTag method="tree">
  2. <ul>
  3. <#list categories as category>
  4. <li>
  5. <a href="${category.fullPath!}">
  6. ${category.name!}
  7. </a>
  8. </li>
  9. <#if category.children?? && category.children?size gt 0>
  10. <@renderCategories category.children></@renderCategories>
  11. </#if>
  12. </#list>
  13. </ul>
  14. </@categoryTag>
  15. <#macro renderCategories categories>
  16. <ul>
  17. <#list categories as category>
  18. <li>
  19. <a href="${category.fullPath!}">
  20. ${(category.name)!}
  21. </a>
  22. <#if category.children?? && category.children?size gt 0>
  23. <@renderCategories category.children></@renderCategories>
  24. </#if>
  25. </li>
  26. </#list>
  27. </ul>
  28. </#macro>

输出:

  1. <ul>
  2. <li>
  3. <a href="http://localhost:8090/categories/parent">
  4. 父级分类
  5. </a>
  6. </li>
  7. <ul>
  8. <li>
  9. <a href="http://localhost:8090/categories/child">
  10. 子分类
  11. </a>
  12. </li>
  13. </ul>
  14. </ul>

获取文章的所有分类(listByPostId)

语法

  1. <@categoryTag method="listByPostId" postId="文章 id">
  2. // do something
  3. </@categoryTag>

参数:

  1. method:listByPostId
  2. postId:文章 id

返回参数

categories:

  1. [{
  2. "createTime": "2020-10-11T05:59:40.622Z",
  3. "description": "string",
  4. "fullPath": "string",
  5. "id": 0,
  6. "name": "string",
  7. "parentId": 0,
  8. "slug": "string",
  9. "thumbnail": "string"
  10. }]

示例

  1. <@categoryTag method="listByPostId" postId="${post.id?c}">
  2. <#list categories as category>
  3. <a href="${category.fullPath!}">${category.name}</a>
  4. </#list>
  5. </@categoryTag>

输出:

  1. <a href="http://localhost:8090/categories/url1">name1</a>
  2. <a href="http://localhost:8090/categories/url2">name2</a>

获取所有分类的数量(count)

语法

  1. <@categoryTag method="count">
  2. // do something
  3. </@categoryTag>

参数:

  1. method:count

返回参数

  1. count: long

示例

  1. <@categoryTag method="count">
  2. <span>分类数量:${count!0}</span>
  3. </@categoryTag>

输出:

  1. <span>分类数量:20</span>

标签(tagTag)

获取所有标签(list)

语法

  1. <@tagTag method="list">
  2. // 返回参数:tags
  3. </@tagTag>

参数:

  1. method:list

返回参数

tags:

  1. [{
  2. "createTime": "2020-10-11T06:14:30.595Z",
  3. "fullPath": "string",
  4. "id": 0,
  5. "name": "string",
  6. "slug": "string",
  7. "thumbnail": "string",
  8. "postCount": 0
  9. }]

示例

  1. <@tagTag method="list">
  2. <#list tags as tag>
  3. <a href="${tag.fullPath!}">${tag.name!}(${tag.postCount!})</a>
  4. </#list>
  5. </@tagTag>

输出:

  1. <a href="http://localhost:8090/tags/url1">name1(1)</a>
  2. <a href="http://localhost:8090/tags/url2">name2(20)</a>

获取文章的所有标签(listByPostId)

语法

  1. <@tagTag method="listByPostId" postId="文章 id">
  2. // do something
  3. </@tagTag>

参数:

  1. method:listByPostId
  2. postId:文章 id

返回参数

tags:

  1. [{
  2. "createTime": "2020-10-11T06:14:30.595Z",
  3. "fullPath": "string",
  4. "id": 0,
  5. "name": "string",
  6. "slug": "string",
  7. "thumbnail": "string"
  8. }]

示例

  1. <@tagTag method="listByPostId" postId="${post.id?c}">
  2. <#list tags as tag>
  3. <a href="${tag.fullPath!}">${tag.name}</a>
  4. </#list>
  5. </@tagTag>

输出:

  1. <a href="http://localhost:8090/tags/url1">name1</a>
  2. <a href="http://localhost:8090/tags/url2">name2</a>

获取所有标签的数量(count)

语法

  1. <@tagTag method="count">
  2. // do something
  3. </@tagTag>

参数:

  1. method:count

返回参数

  1. count: long

示例

  1. <@tagTag method="count">
  2. <span>标签数量:${count!0}</span>
  3. </@tagTag>

输出:

  1. <span>标签数量:20</span>

菜单(menuTag)

获取所有菜单(list)

语法

  1. <@menuTag method="list">
  2. // do something
  3. </@menuTag>

参数:

  1. method:list

返回参数

menus:

  1. [{
  2. "icon": "string",
  3. "id": 0,
  4. "name": "string",
  5. "parentId": 0,
  6. "priority": 0,
  7. "target": "string",
  8. "team": "string",
  9. "url": "string"
  10. }]

示例

  1. <@menuTag method="list">
  2. <ul>
  3. <#list menus as menu>
  4. <li>
  5. <a href="${menu.url!}" target="${menu.target!}">${menu.name!}</a>
  6. </li>
  7. </#list>
  8. </ul>
  9. </@menuTag>

输出:

  1. <ul>
  2. <li>
  3. <a href="/" target="_blank">首页</a>
  4. </li>
  5. <li>
  6. <a href="/archives" target="_blank">归档</a>
  7. </li>
  8. </ul>

获取多级菜单(tree)

语法

  1. <@menuTag method="tree">
  2. // do something
  3. </@menuTag>

参数:

  1. method:tree

返回参数

menus:

  1. [{
  2. "children": [{
  3. "children": [{}],
  4. "icon": "string",
  5. "id": 0,
  6. "name": "string",
  7. "parentId": 0,
  8. "priority": 0,
  9. "target": "string",
  10. "team": "string",
  11. "url": "string"
  12. }],
  13. "icon": "string",
  14. "id": 0,
  15. "name": "string",
  16. "parentId": 0,
  17. "priority": 0,
  18. "target": "string",
  19. "team": "string",
  20. "url": "string"
  21. }]

示例

  1. <@menuTag method="tree">
  2. <ul>
  3. <#list menus as menu>
  4. <li>
  5. <a href="${menu.url!}" target="${menu.target!}">${menu.name!}</a>
  6. <#if menu.children?? && menu.children?size gt 0>
  7. <ul>
  8. <#list menu.children as child>
  9. <li>
  10. <a href="${child.url!}" target="${menu.target!}">${child.name!}</a>
  11. </li>
  12. </#list>
  13. </ul>
  14. </#if>
  15. </li>
  16. </#list>
  17. </ul>
  18. </@menuTag>

输出:

  1. <ul>
  2. <li>
  3. <a href="/" target="_blank">首页</a>
  4. </li>
  5. <li>
  6. <a href="/archives" target="_blank">归档</a>
  7. <ul>
  8. <li>
  9. <a href="/categories/study" target="_blank">学习笔记</a>
  10. </li>
  11. <li>
  12. <a href="/categories/java" target="_blank">Java</a>
  13. </li>
  14. </ul>
  15. </li>
  16. </ul>

根据分组获取菜单(listByTeam)

语法

  1. <@menuTag method="listByTeam" team="team 名称">
  2. // do something
  3. </@menuTag>

参数:

  1. method:listByTeam
  2. team:team 名称

返回参数

menus:

  1. [{
  2. "icon": "string",
  3. "id": 0,
  4. "name": "string",
  5. "parentId": 0,
  6. "priority": 0,
  7. "target": "string",
  8. "team": "string",
  9. "url": "string"
  10. }]

示例

  1. <@menuTag method="listByTeam" team="main">
  2. <ul>
  3. <#list menus as menu>
  4. <li>
  5. <a href="${menu.url!}" target="${menu.target!}">${menu.name!}</a>
  6. </li>
  7. </#list>
  8. </ul>
  9. </@menuTag>

输出:

  1. <ul>
  2. <li>
  3. <a href="/" target="_blank">首页</a>
  4. </li>
  5. <li>
  6. <a href="/archives" target="_blank">归档</a>
  7. </li>
  8. </ul>

根据分组获取多级菜单(treeByTeam)

语法

  1. <@menuTag method="treeByTeam" team="team 名称">
  2. // do something
  3. </@menuTag>

参数:

  1. method:treeByTeam
  2. team:team 名称

返回参数

menus:

  1. [{
  2. "children": [{
  3. "children": [{}],
  4. "icon": "string",
  5. "id": 0,
  6. "name": "string",
  7. "parentId": 0,
  8. "priority": 0,
  9. "target": "string",
  10. "team": "string",
  11. "url": "string"
  12. }],
  13. "icon": "string",
  14. "id": 0,
  15. "name": "string",
  16. "parentId": 0,
  17. "priority": 0,
  18. "target": "string",
  19. "team": "string",
  20. "url": "string"
  21. }]

示例

  1. <@menuTag method="treeByTeam" team="main">
  2. <ul>
  3. <#list menus as menu>
  4. <li>
  5. <a href="${menu.url!}" target="${menu.target!}">${menu.name!}</a>
  6. <#if menu.children?? && menu.children?size gt 0>
  7. <ul>
  8. <#list menu.children as child>
  9. <li>
  10. <a href="${child.url!}" target="${menu.target!}">${child.name!}</a>
  11. </li>
  12. </#list>
  13. </ul>
  14. </#if>
  15. </li>
  16. </#list>
  17. </ul>
  18. </@menuTag>

输出:

  1. <ul>
  2. <li>
  3. <a href="/" target="_blank">首页</a>
  4. </li>
  5. <li>
  6. <a href="/archives" target="_blank">归档</a>
  7. <ul>
  8. <li>
  9. <a href="/categories/study" target="_blank">学习笔记</a>
  10. </li>
  11. <li>
  12. <a href="/categories/java" target="_blank">Java</a>
  13. </li>
  14. </ul>
  15. </li>
  16. </ul>

友情链接(linkTag)

获取所有友情链接(list)

语法

  1. <@linkTag method="list">
  2. // do something
  3. </@linkTag>

参数:

  1. method:list

返回参数

links:

  1. [{
  2. "id": 0,
  3. "name": "string",
  4. "url": "string",
  5. "logo": "string",
  6. "description": "string",
  7. "team": "string",
  8. "priority": 0,
  9. "createTime": "2021-01-10 20:48:00",
  10. "updateTime": "2021-01-10 20:48:00"
  11. }]

示例

  1. <ul>
  2. <@linkTag method="list">
  3. <#list links as link>
  4. <li>
  5. <a href="${link.url!}" target="_blank">
  6. ${link.name!}
  7. </a>
  8. </li>
  9. </#list>
  10. </@linkTag>
  11. </ul>

输出:

  1. <ul>
  2. <li>
  3. <a href="https://halo.run" target="_blank">
  4. Halo
  5. </a>
  6. </li>
  7. <li>
  8. <a href="https://bbs.halo.run" target="_blank">
  9. Halo BBS
  10. </a>
  11. </li>
  12. </ul>

乱序获取所有友情链接(listByRandom)

语法

  1. <@linkTag method="listByRandom">
  2. // do something
  3. </@linkTag>

参数:

  1. method:listByRandom

返回参数

  1. [{
  2. "id": 0,
  3. "name": "string",
  4. "url": "string",
  5. "logo": "string",
  6. "description": "string",
  7. "team": "string",
  8. "priority": 0,
  9. "createTime": "2021-01-10 20:48:00",
  10. "updateTime": "2021-01-10 20:48:00"
  11. }]

示例

  1. <ul>
  2. <@linkTag method="list">
  3. <#list links as link>
  4. <li>
  5. <a href="${link.url!}" target="_blank">
  6. ${link.name!}
  7. </a>
  8. </li>
  9. </#list>
  10. </@linkTag>
  11. </ul>

输出:

  1. <ul>
  2. <li>
  3. <a href="https://bbs.halo.run" target="_blank">
  4. Halo BBS
  5. </a>
  6. </li>
  7. <li>
  8. <a href="https://halo.run" target="_blank">
  9. Halo
  10. </a>
  11. </li>
  12. </ul>

获取分组友情链接(listTeams)

语法

  1. <@linkTag method="listTeams">
  2. // do something
  3. </@linkTag>

参数:

  1. method:listTeams

返回参数

teams:

  1. [{
  2. "team": "string",
  3. "links": [{
  4. "id": 0,
  5. "name": "string",
  6. "url": "string",
  7. "logo": "string",
  8. "description": "string",
  9. "team": "string",
  10. "priority": 0
  11. }]
  12. }]

示例

  1. <@linkTag method="listTeams">
  2. <#list teams as team>
  3. <h1>${team.team}</h1>
  4. <ul>
  5. <#list links as link>
  6. <li>
  7. <a href="${link.url!}" target="_blank">
  8. ${link.name!}
  9. </a>
  10. </li>
  11. </#list>
  12. </ul>
  13. </#list>
  14. </@linkTag>

输出:

  1. <h1>Halo 相关</h1>
  2. <ul>
  3. <li>
  4. <a href="https://bbs.halo.run" target="_blank">
  5. Halo BBS
  6. </a>
  7. </li>
  8. <li>
  9. <a href="https://halo.run" target="_blank">
  10. Halo
  11. </a>
  12. </li>
  13. </ul>
  14. <h1>网友们</h1>
  15. <ul>
  16. <li>
  17. <a href="https://ryanc.cc" target="_blank">
  18. Ryan Wang's Blog
  19. </a>
  20. </li>
  21. <li>
  22. <a href="https://johnniang.me" target="_blank">
  23. JohnNiang's Blog
  24. </a>
  25. </li>
  26. </ul>

乱序获取分组友情链接(listTeamsByRandom)

语法

  1. <@linkTag method="listTeamsByRandom">
  2. // do something
  3. </@linkTag>

参数:

  1. method:listTeamsByRandom

返回参数

teams:

  1. [{
  2. "team": "string",
  3. "links": [{
  4. "id": 0,
  5. "name": "string",
  6. "url": "string",
  7. "logo": "string",
  8. "description": "string",
  9. "team": "string",
  10. "priority": 0
  11. }]
  12. }]

示例

  1. <@linkTag method="listTeamsByRandom">
  2. <#list teams as team>
  3. <h1>${team.team}</h1>
  4. <ul>
  5. <#list links as link>
  6. <li>
  7. <a href="${link.url!}" target="_blank">
  8. ${link.name!}
  9. </a>
  10. </li>
  11. </#list>
  12. </ul>
  13. </#list>
  14. </@linkTag>

输出:

  1. <h1>Halo 相关</h1>
  2. <ul>
  3. <li>
  4. <a href="https://bbs.halo.run" target="_blank">
  5. Halo BBS
  6. </a>
  7. </li>
  8. <li>
  9. <a href="https://halo.run" target="_blank">
  10. Halo
  11. </a>
  12. </li>
  13. </ul>
  14. <h1>网友们</h1>
  15. <ul>
  16. <li>
  17. <a href="https://ryanc.cc" target="_blank">
  18. Ryan Wang's Blog
  19. </a>
  20. </li>
  21. <li>
  22. <a href="https://johnniang.me" target="_blank">
  23. JohnNiang's Blog
  24. </a>
  25. </li>
  26. </ul>

获取所有友情链接的数量(count)

语法

  1. <@linkTag method="count">
  2. // do something
  3. </@linkTag>

参数:

  1. method:count

返回参数

  1. count: long

示例

  1. <@linkTag method="count">
  2. <span>友情链接数量:${count!0}</span>
  3. </@linkTag>

输出:

  1. <span>友情链接数量:20</span>

图库(photoTag)

获取所有图片(list)

语法

  1. <@photoTag method="list">
  2. // do something
  3. </@photoTag>

参数:

  1. method:list

返回参数

photos:

  1. [{
  2. "id": 0,
  3. "name": "string",
  4. "description": "string",
  5. "takeTime": "2021-01-10 20:48:00",
  6. "location": "string",
  7. "thumbnail": "string",
  8. "url": "string",
  9. "team": "string",
  10. "createTime": "2021-01-10 20:48:00",
  11. "updateTime": "2021-01-10 20:48:00"
  12. }]

示例

  1. <@photoTag method="list">
  2. <#list photos as photo>
  3. <img alt="${photo.description}" src="${photo.url}"/>
  4. </#list>
  5. </@photoTag>

输出:

  1. <img alt="山川" src="https://youdomain.com/upload/2021/01/1.png"/>
  2. <img alt="河流" src="https://youdomain.com/upload/2021/01/2.png"/>
  3. <img alt="绿树" src="https://youdomain.com/upload/2021/01/3.png"/>

获取所有分组图片(listTeams)

语法

  1. <@photoTag method="listTeams">
  2. // do something
  3. </@photoTag>

参数:

  1. method:listTeams

返回参数

teams:

  1. [{
  2. "team": "string",
  3. "photos": [{
  4. "id": 0,
  5. "name": "string",
  6. "thumbnail": "string",
  7. "takeTime": "2021-01-10 20:48:00",
  8. "url": "string",
  9. "team": "string",
  10. "location": "string",
  11. "description": "string"
  12. }]
  13. }]

示例

  1. <@photoTag method="listTeams">
  2. <#list teams as team>
  3. <h1>${team.team}</h1>
  4. <#list team.photos as photo>
  5. <img alt="${photo.description}" src="${photo.url}"/>
  6. </#list>
  7. </#list>
  8. </@photoTag>

输出:

  1. <h1>风景</h1>
  2. <img alt="山川" src="https://youdomain.com/upload/2021/01/1.png"/>
  3. <img alt="河流" src="https://youdomain.com/upload/2021/01/2.png"/>
  4. <img alt="绿树" src="https://youdomain.com/upload/2021/01/3.png"/>
  5. <h1>旅行</h1>
  6. <img alt="四川" src="https://youdomain.com/upload/2021/02/1.png"/>
  7. <img alt="重庆" src="https://youdomain.com/upload/2021/02/2.png"/>
  8. <img alt="深圳" src="https://youdomain.com/upload/2021/02/3.png"/>

根据分组获取图片(listByTeam)

语法

  1. <@photoTag method="listByTeam" team="team 名称">
  2. // do something
  3. </@photoTag>

参数:

  1. method:listByTeam
  2. team:team 名称

返回参数

photos:

  1. [{
  2. "id": 0,
  3. "name": "string",
  4. "description": "string",
  5. "takeTime": "2021-01-10 20:48:00",
  6. "location": "string",
  7. "thumbnail": "string",
  8. "url": "string",
  9. "team": "string",
  10. "createTime": "2021-01-10 20:48:00",
  11. "updateTime": "2021-01-10 20:48:00"
  12. }]

示例

  1. <@photoTag method="listTeams" team="风景">
  2. <#list team.photos as photo>
  3. <img alt="${photo.description}" src="${photo.url}"/>
  4. </#list>
  5. </@photoTag>

输出:

  1. <img alt="山川" src="https://youdomain.com/upload/2021/01/1.png"/>
  2. <img alt="河流" src="https://youdomain.com/upload/2021/01/2.png"/>
  3. <img alt="绿树" src="https://youdomain.com/upload/2021/01/3.png"/>

获取所有图片的数量(count)

语法

  1. <@photoTag method="count">
  2. // do something
  3. </@photoTag>

参数:

  1. method:count

返回参数

  1. count: long

示例

  1. <@linkTag method="count">
  2. <span>图片数量:${count!0}</span>
  3. </@linkTag>

输出:

  1. <span>图片数量:20</span>

分页(paginationTag)

获取首页文章列表的分页数据(index)

语法

  1. <@paginationTag method="index" page="${posts.number}" total="${posts.totalPages}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:index
  2. page:当前页,通过 ${posts.number} 得到
  3. total:总页数,通过 ${posts.totalPages} 得到
  4. display:页码展示数量

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="index" page="${posts.number}" total="${posts.totalPages}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/page/1">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/page/1">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/page/3">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/page/3">下一页</a>
  16. </li>
  17. </ul>

获取文章归档列表的分页数据(archives)

语法

  1. <@paginationTag method="archives" page="${posts.number}" total="${posts.totalPages}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:archives
  2. page:当前页,通过 ${posts.number} 得到
  3. total:总页数,通过 ${posts.totalPages} 得到
  4. display:页码展示数量

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="archives" page="${posts.number}" total="${posts.totalPages}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/archives/page/1">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/archives/page/1">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/archives/page/3">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/archives/page/3">下一页</a>
  16. </li>
  17. </ul>

获取搜索结果文章列表的分页数据(search)

语法

  1. <@paginationTag method="search" page="${posts.number}" total="${posts.totalPages}" keyword="${keyword}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:search
  2. page:当前页,通过 ${posts.number} 得到
  3. total:总页数,通过 ${posts.totalPages} 得到
  4. keyword: 关键词
  5. display:页码展示数量

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="search" page="${posts.number}" total="${posts.totalPages}" keyword="${keyword}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/search/page/1?keyword=keyword">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/search/page/1?keyword=keyword">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/search/page/3?keyword=keyword">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/search/page/3?keyword=keyword">下一页</a>
  16. </li>
  17. </ul>

获取标签下文章列表的分页数据(tagPosts)

语法

  1. <@paginationTag method="tagPosts" slug="${tag.slug!}" page="${posts.number}" total="${posts.totalPages}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:tagPosts
  2. page:当前页,通过 ${posts.number} 得到
  3. total:总页数,通过 ${posts.totalPages} 得到
  4. display:页码展示数量
  5. slug:标签 slug

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="tagPosts" slug="${tag.slug!}" page="${posts.number}" total="${posts.totalPages}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/tags/demo/page/1">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/tags/demo/page/1">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/tags/demo/page/3">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/tags/demo/page/3">下一页</a>
  16. </li>
  17. </ul>

获取分类下文章列表的分页数据(categoryPosts)

语法

  1. <@paginationTag method="categoryPosts" slug="${category.slug!}" page="${posts.number}" total="${posts.totalPages}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:categoryPosts
  2. page:当前页,通过 ${posts.number} 得到
  3. total:总页数,通过 ${posts.totalPages} 得到
  4. display:页码展示数量
  5. slug:标签 slug

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="categoryPosts" slug="${category.slug!}" page="${posts.number}" total="${posts.totalPages}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/categories/demo/page/1">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/categories/demo/page/1">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/categories/demo/page/3">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/categories/demo/page/3">下一页</a>
  16. </li>
  17. </ul>

获取图库页面图片列表的分页数据(photos)

语法

  1. <@paginationTag method="photos" page="${photos.number}" total="${photos.totalPages}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:photos
  2. page:当前页,通过 ${photos.number} 得到
  3. total:总页数,通过 ${photos.totalPages} 得到
  4. display:页码展示数量

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="photos" page="${photos.number}" total="${photos.totalPages}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/photos/page/1">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/photos/page/1">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/photos/page/3">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/photos/page/3">下一页</a>
  16. </li>
  17. </ul>

获取日志页面日志列表的分页数据(journals)

语法

  1. <@paginationTag method="journals" page="${journals.number}" total="${journals.totalPages}" display="3">
  2. // do something
  3. </@paginationTag>

参数:

  1. method:journals
  2. page:当前页,通过 ${journals.number} 得到
  3. total:总页数,通过 ${journals.totalPages} 得到
  4. display:页码展示数量

返回参数

pagination:

  1. {
  2. "nextPageFullPath": "string",
  3. "prevPageFullPath": "string",
  4. "hasPrev": true,
  5. "hasNext": true,
  6. "rainbowPages": [{
  7. "page": 0,
  8. "fullPath": "string",
  9. "isCurrent": true
  10. }]
  11. }

示例

  1. <ul class="pagination">
  2. <@paginationTag method="journals" page="${journals.number}" total="${journals.totalPages}" display="3">
  3. <#if pagination.hasPrev>
  4. <li>
  5. <a href="${pagination.prevPageFullPath!}">上一页</a>
  6. </li>
  7. </#if>
  8. <#list pagination.rainbowPages as number>
  9. <#if number.isCurrent>
  10. <li>
  11. <span class="current">${number.page!}</span>
  12. </li>
  13. <#else>
  14. <li>
  15. <a href="${number.fullPath!}">${number.page!}</a>
  16. </li>
  17. </#if>
  18. </#list>
  19. <#if pagination.hasNext>
  20. <li>
  21. <a href="${pagination.nextPageFullPath!}">下一页</a>
  22. </li>
  23. </#if>
  24. </@paginationTag>
  25. </ul>

输出:

  1. <ul class="pagination">
  2. <li>
  3. <a href="http://localhost:8090/journals/page/1">上一页</a>
  4. </li>
  5. <li>
  6. <a href="http://localhost:8090/journals/page/1">1</a>
  7. </li>
  8. <li>
  9. <span class="current">2</span>
  10. </li>
  11. <li>
  12. <a href="http://localhost:8090/journals/page/3">3</a>
  13. </li>
  14. <li>
  15. <a href="http://localhost:8090/journals/page/3">下一页</a>
  16. </li>
  17. </ul>