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

categories-for-support-team.js 1.5 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
46
47
48
49
50
51
52
53
54
  1. const path = require('path')
  2. module.exports = async function categoriesForSupportTeam (req, res, next) {
  3. const englishSiteTree = req.context.siteTree.en
  4. const allCategories = []
  5. Object.keys(englishSiteTree).forEach(version => {
  6. const versionedProductsTree = englishSiteTree[version].products
  7. Object.values(versionedProductsTree).forEach(productObj => {
  8. if (productObj.id === 'early-access') return
  9. if (productObj.external) return
  10. Object.values(productObj.categories).forEach(categoryObj => {
  11. const articlesArry = []
  12. if (categoryObj.maptopics) {
  13. Object.values(categoryObj.maptopics).forEach(maptopicObj => {
  14. Object.values(maptopicObj.articles).forEach(articleObj => {
  15. articlesArry.push({
  16. title: articleObj.title,
  17. slug: path.basename(articleObj.href)
  18. })
  19. })
  20. })
  21. }
  22. if (categoryObj.standalone) {
  23. articlesArry.push({
  24. title: categoryObj.title,
  25. slug: path.basename(categoryObj.href)
  26. })
  27. }
  28. if (categoryObj.articles) {
  29. Object.values(categoryObj.articles).forEach(articleObj => {
  30. articlesArry.push({
  31. title: articleObj.title,
  32. slug: path.basename(articleObj.href)
  33. })
  34. })
  35. }
  36. allCategories.push({
  37. name: categoryObj.title,
  38. published_articles: articlesArry
  39. })
  40. })
  41. })
  42. })
  43. return res.json(allCategories)
  44. }
Tip!

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

Comments

Loading...