import { useRoute } from 'vue-router';
import { computed } from 'vue';

export function useRouteConfig(props: Recordable = {}) {
  const route = useRoute();
  function getMeta(key?: string) {
    if (key) {
      return route.meta[key];
    }
    return route.meta;
  }

  const getTitle = computed(() => {
    return getMeta('title') || props.title;
  });

  return { getMeta, getTitle };
}