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.4KB

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