You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pages-sections.md 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. +++
  2. title = "Sections and Pages"
  3. weight = 20
  4. +++
  5. Pages and sections are actually very similar.
  6. ## Page variables
  7. Gutenberg will try to load the `templates/page.html` template, the `page.html` template of the theme if one is used
  8. or will render the built-in template: a blank page.
  9. Whichever template you decide to render, you will get a `page` variable in your template
  10. with the following fields:
  11. ```ts
  12. content: String;
  13. title: String?;
  14. description: String?;
  15. date: String?;
  16. slug: String;
  17. path: String;
  18. permalink: String;
  19. summary: String?;
  20. tags: Array<String>;
  21. category: String?;
  22. extra: HashMap<String, Any>;
  23. // Naive word count, will not work for languages without whitespace
  24. word_count: Number;
  25. // Based on https://help.medium.com/hc/en-us/articles/214991667-Read-time
  26. reading_time: Number;
  27. // `previous` and `next` are only filled if the content can be sorted
  28. previous: Page?;
  29. next: Page?;
  30. // See the Table of contents section below for more details
  31. toc: Array<Header>;
  32. ```
  33. ## Section variables
  34. By default, Gutenberg will try to load `templates/section.html`. If there isn't
  35. one, it will render the built-in template: a blank page.
  36. Whichever template you decide to render, you will get a `section` variable in your template
  37. with the following fields:
  38. ```ts
  39. content: String;
  40. title: String?;
  41. description: String?;
  42. date: String?;
  43. slug: String;
  44. path: String;
  45. permalink: String;
  46. extra: HashMap<String, Any>;
  47. // Pages directly in this section, sorted if asked
  48. pages: Array<Pages>;
  49. // Direct subsections to this section, sorted by subsections weight
  50. subsections: Array<Section>;
  51. // Naive word count, will not work for languages without whitespace
  52. word_count: Number;
  53. // Based on https://help.medium.com/hc/en-us/articles/214991667-Read-time
  54. reading_time: Number;
  55. // See the Table of contents section below for more details
  56. toc: Array<Header>;
  57. ```
  58. ## Table of contents
  59. Both page and section have a `toc` field which corresponds to an array of `Header`.
  60. A `Header` has the following fields:
  61. ```ts
  62. // The hX level
  63. level: 1 | 2 | 3 | 4 | 5 | 6;
  64. // The generated slug id
  65. id: String;
  66. // The text of the header
  67. title: String;
  68. // A link pointing directly to the header, using the inserted anchor
  69. permalink: String;
  70. // All lower level headers below this header
  71. children: Array<Header>;
  72. ```