Quest descriptions
Structured content rendered into your design.
Descriptions are written in the admin panel with formatting: paragraphs, bold, lists, links. They arrive as structured content, not a string, so they can carry that formatting into your design without any HTML from us.
Rendering
import { Quest } from '@xborglabs/fanbase-react'
<Quest.Description theme={descriptionTheme} />Do not try to render the raw value. It is a node tree, and JSON.stringify on a quest description is a recognisable sign of a rushed integration.
The theme object
You map node types to your own class names. Nothing is styled by us.
const descriptionTheme = {
paragraph: 'your-prose-p',
heading: {
h1: 'your-h1',
h2: 'your-h2',
h3: 'your-h3',
},
list: {
ul: 'your-ul',
ol: 'your-ol',
listitem: 'your-li',
},
link: 'your-link',
text: {
bold: 'font-bold',
italic: 'italic',
underline: 'underline',
strikethrough: 'line-through',
},
quote: 'your-blockquote',
code: 'your-code',
}Define it once, export it, use it everywhere a description renders. Full key list in Components.
Excerpts for cards
A card usually wants a couple of lines of plain text rather than the full render. Extract the text nodes:
import { Parser } from '@xborglabs/fanbase-react'
function excerpt(description, max = 120) {
const text = Parser.toPlainText(description)
return text.length > max ? `${text.slice(0, max).trimEnd()}…` : text
}Empty descriptions
Not every quest has one. Check before you render a wrapper with nothing in it.
{state.quest?.description ? (
<div className="your-description">
<Quest.Description theme={descriptionTheme} />
</div>
) : null}Links inside descriptions
Community teams put links in descriptions. Style them through theme.link and they inherit your link styles.
If the quest is a visit-link quest, the CTA is what the machine watches, not a link in the description. See Visit-link quests.