<template>
  <div class="text-right text-gray-400 dark:text-gray-600 text-sm">
    <div class="font-semibold">
      {{ $t('page.updatedAt') }}
      {{ $d(Date.parse(document.updatedAt), 'short').replace(',', ' à') }}
    </div>

    <a
      :href="`https://monnaie-libre.fr/admin/#/collections${document.dir}/entries/${document.slug}`"
      target="_blank"
      rel="noopener noreferrer"
      class="hover:underline block"
    >
      {{ $t('page.editAdmin') }}
    </a>

    <a
      v-if="$store.state.rootPath"
      :href="linkVSCode"
      target="_blank"
      rel="noopener noreferrer"
      class="hover:underline block"
    >
      {{ $t('page.editVscode') }}
    </a>
  </div>
</template>

<script>
export default {
  name: 'PageEdit',
  props: {
    document: {
      type: Object,
      required: true,
    },
  },
  computed: {
    linkVSCode() {
      if (!this.$store.state.rootPath) return null
      const editor = process.env.DEV_EDITOR_HYPERLINK_BASE || 'vscode://file'
      return (
        editor +
        this.$store.state.rootPath +
        '/content' +
        this.document.path +
        this.document.extension
      )
    },
  },
}
</script>