The topic variable describes the current topic. It is only available in the Topic template designer.
The structure of topic is as follows:
{
"tocId": "IIS7zZcAMtq9SgiS6gVupw",
"contentId": "wDGWmDHxJ70v3b3pkmpo0Q",
"title": "Introduction",
"hasRating": false,
"prettyUrl": "r/Reader-Designer/Introduction",
"depth": 1,
"children": []
}
| Field | Type | Description |
|---|---|---|
tocId |
String | The value of the tocId metadata key for the currently open topic. |
contentId |
String | The value of the contentId metadata key for the currently open topic. |
title |
String | The value of the ft:title metadata key for the currently open topic. |
hasRating |
Boolean | Indicates whether the currently open topic has a rating or not. |
prettyUrl |
String | The URL of the topic. |
depth |
Number | The table of contents hierarchy. 1 corresponds to the highest level of topics. |
parentTocId |
String | The value of the tocId metadata key for the currently open topic's parent topic. |
children |
Array | The same values contained in this table, for children topics of the currently open topic. |
The topic variable also includes the following JavaScript methods:
| Method | Description |
|---|---|
topic.getMetadata() |
Returns the metadata of the current topic. |
topic.getContent() |
Returns the HTML content of the current topic. |
topic.getRating() |
Returns information about the rating given to the current topic. |
topic.rate() |
Allows designers to rate a topic. |
topic.unrate() |
Allows designers to unrate a topic. |
topic.sendFeedback() |
Allows designers to send feedback about a topic. |