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

all-products.js 1.4 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  1. const fs = require('fs')
  2. const path = require('path')
  3. const frontmatter = require('./read-frontmatter')
  4. const getApplicableVersions = require('./get-applicable-versions')
  5. const removeFPTFromPath = require('./remove-fpt-from-path')
  6. // Both internal and external products are specified in content/index.md
  7. const homepage = path.posix.join(process.cwd(), 'content/index.md')
  8. const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
  9. const productIds = data.children
  10. const externalProducts = data.externalProducts
  11. const internalProducts = {}
  12. productIds.forEach(productId => {
  13. const relPath = productId
  14. const dir = path.posix.join('content', relPath)
  15. // Early Access may not exist in the current checkout
  16. if (!fs.existsSync(dir)) return
  17. const toc = path.posix.join(dir, 'index.md')
  18. const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))
  19. const applicableVersions = getApplicableVersions(data.versions, toc)
  20. const href = removeFPTFromPath(path.posix.join('/', applicableVersions[0], productId))
  21. internalProducts[productId] = {
  22. id: productId,
  23. name: data.shortTitle || data.title,
  24. href,
  25. dir,
  26. toc,
  27. wip: data.wip || false,
  28. hidden: data.hidden || false
  29. }
  30. internalProducts[productId].versions = applicableVersions
  31. })
  32. const productMap = Object.assign({}, internalProducts, externalProducts)
  33. module.exports = {
  34. productIds,
  35. productMap
  36. }
Tip!

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

Comments

Loading...