Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

1.6 KB
Raw Blame
import { useLocalePath, useRoute } from "#imports"
import { computed } from "vue"

import { getRouteNameString } from "#shared/utils/route-utils"

export default function usePages() {
  const localePath = useLocalePath()

  const pages = [
    {
      id: "about",
      name: "navigation.about",
      link: localePath("/about"),
    },
    {
      id: "licenses",
      name: "navigation.licenses",
      link: "https://creativecommons.org/share-your-work/cclicenses/",
    },
    {
      id: "sources",
      name: "navigation.sources",
      link: localePath("/sources"),
    },
    {
      id: "search-help",
      name: "navigation.searchHelp",
      link: localePath("/search-help"),
    },
    {
      id: "get-involved",
      name: "navigation.getInvolved",
      link: "https://make.wordpress.org/openverse/handbook/",
    },
    {
      id: "api",
      name: "navigation.api",
      link: "https://api.openverse.org/v1/",
    },
    {
      id: "terms",
      name: "navigation.terms",
      link: "https://docs.openverse.org/terms_of_service.html",
    },
    {
      id: "privacy",
      name: "navigation.privacy",
      link: localePath("/privacy"),
    },
    {
      id: "feedback",
      name: "navigation.feedback",
      link: localePath("/feedback"),
    },
  ]

  const route = useRoute()
  /**
   * The route name of the current page is localized, so it looks like `index__en`.
   * We need to remove the locale suffix to match the page id.
   */
  const currentPageId = computed<string>(
    () => getRouteNameString(route).split("__")[0] ?? ""
  )

  return { all: pages, current: currentPageId }
}