User Preferences
User preferences allow you to customize content depending on the reader's preference.
For example, if some features of your product are only available on specific plans, you can let your users select their plan, so that they're only shown relevant content. See the dynamic content section for a how-to guide.
Doctave will automatically add a user preference selector to your header if you have enabled this feature.
Creating user preferences
To create a user preference, add a user preference object to your project file.
A user preference is a key-value pair that Doctave will use to customize the rendering of your documentation. See reference.
---
title: My Project
user_preferences:
plan:
label: My Plan
default: Starter
values:
- Starter
- Growth
- Enterprise
You can specify the available values and the default value for a user preference.
Adding a customized label for user preferences
You can choose to customize the label that's shown in the user preference selector.
Instead of using plain text for values, use the complex format:
---
title: My Project
user_preferences:
plan:
label: My Plan
default: starter
values:
- label: Starter Plan for Beginners
value: starter
- label: Growth Plan
value: growth
- label: Enterprise
value: enterprise
Accessing user preferences in markdown
The specified user preferences are exposed as variables which can be used by the Doctave templating system.
User preferences are accessible under the DOCTAVE.user_preferences
key.
In the above example, you could access the user's plan preference through DOCTAVE.user_preferences.plan
.
Was this page helpful?