useNavigation.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { createSharedComposable } from '@vueuse/core'
  2. export interface HeaderLink {
  3. label: string
  4. description: string
  5. icon: string
  6. to: string
  7. search?: boolean
  8. children?: HeaderLink[]
  9. }
  10. function _useHeaderLinks() {
  11. const route = useRoute()
  12. const headerLinks = computed<HeaderLink[]>(() => {
  13. const to = ''
  14. return [{
  15. label: 'Get Started',
  16. description: 'Learn how to get started with TresJS to build your 3D first app.',
  17. icon: 'i-lucide-rocket',
  18. to: `${to}/getting-started`,
  19. active: route.path.startsWith(`${to}/getting-started`),
  20. }, {
  21. label: 'Essentials',
  22. description: 'Get the key concepts and best practices.',
  23. icon: 'i-lucide-book-open',
  24. to: `${to}/essentials`,
  25. active: route.path.startsWith(`${to}/essentials`),
  26. }, {
  27. label: 'API',
  28. description: 'Explore the TresJS components, composables, utilities and more.',
  29. icon: 'i-lucide-code-xml',
  30. to: `${to}/api`,
  31. active: route.path.startsWith(`${to}/api`),
  32. }, {
  33. label: 'Cookbook',
  34. description: 'Discover and explore official and community examples.',
  35. icon: 'i-lucide-cooking-pot',
  36. to: `${to}/cookbook`,
  37. active: route.path.startsWith(`${to}/cookbook`),
  38. }/* { label: 'Community', description: 'Find answers and support from the community.', icon: 'i-lucide-messages-square', to: `${to}/community`, active: route.path.startsWith(`${to}/community`) } */]
  39. })
  40. return { headerLinks }
  41. }
  42. export const useHeaderLinks = import.meta.client ? createSharedComposable(_useHeaderLinks) : _useHeaderLinks