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

get-document-type.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
23
24
25
26
27
28
29
30
31
32
33
34
  1. // This function derives the document type from the *relative path* segment length,
  2. // where a relative path refers to the content path starting with the product dir.
  3. // For example: actions/index.md or github/getting-started-with-github/quickstart.md.
  4. module.exports = function getDocumentType (relativePath) {
  5. // A non-index file is ALWAYS considered an article in this approach,
  6. // even if it's at the category level (like actions/quickstart.md)
  7. if (!relativePath.endsWith('index.md')) {
  8. return 'article'
  9. }
  10. const segmentLength = relativePath.split('/').length
  11. // Early Access has an extra tree segment, so it has a different number of segments.
  12. const isEarlyAccess = relativePath.startsWith('early-access')
  13. const publicDocs = {
  14. 1: 'homepage',
  15. 2: 'product',
  16. 3: 'category',
  17. 4: 'mapTopic'
  18. }
  19. const earlyAccessDocs = {
  20. 1: 'homepage',
  21. 2: 'early-access',
  22. 3: 'product',
  23. 4: 'category',
  24. 5: 'mapTopic'
  25. }
  26. return isEarlyAccess
  27. ? earlyAccessDocs[segmentLength]
  28. : publicDocs[segmentLength]
  29. }
Tip!

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

Comments

Loading...