Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

product-examples.js 1.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  1. const getApplicableVersions = require('../../lib/get-applicable-versions')
  2. module.exports = async function productExamples (req, res, next) {
  3. if (!req.context.page) return next()
  4. if (req.context.currentLayoutName !== 'product-landing') return next()
  5. const productExamples = req.context.site.data['product-examples'][req.context.currentProduct]
  6. if (!productExamples) return next()
  7. req.context.productCommunityExamples = productExamples['community-examples']
  8. req.context.productUserExamples = productExamples['user-examples']
  9. // We currently only support versioning in code examples.
  10. // TODO support versioning across all example types.
  11. req.context.productCodeExamples = productExamples['code-examples'] && productExamples['code-examples']
  12. .filter(example => {
  13. // If an example block does NOT contain the versions prop, assume it's available in all versions
  14. return !example.versions || getApplicableVersions(example.versions).includes(req.context.currentVersion)
  15. })
  16. return next()
  17. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...