import { useTitle } from "@vueuse/core";

const DEFAULT_TITLE = "Agent";

const DEFAULT_DESCRIPTION = document
  .querySelector("meta[name='description']")
  ?.getAttribute("content");

export function setTitle(title?: string) {
  useTitle().value = (title ? `${title} | ` : "") + DEFAULT_TITLE;
}

export function resetDescription() {
  document
    .querySelector("meta[name='description']")
    ?.setAttribute("content", DEFAULT_DESCRIPTION!);
}

export function setDescription(description?: string) {
  if (!description) return;
  document
    .querySelector("meta[name='description']")
    ?.setAttribute("content", `${description} | ${DEFAULT_TITLE}`);
}
