<template>
    <span @click="downloadFile">{{ title }}</span>
  </template>
  
  <script>
  export default {
    name: 'DownloadLink',
    props: {
      title: {
        type: String,
        required: true,
      },
      hash: {
        type: String,
        required: true,
      },
      extension: {
        type: String,
        required: true,
      },
    },
    methods: {
      downloadFile() {
        const filePath = `${__dirname}/files/uploads/${this.hash}${this.extension}`;
        const link = document.createElement('a');
        link.href = filePath;
        link.download = this.title + this.extension;
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      },
    },
  };
  </script>
  
  <style scoped>
  span {
    cursor: pointer;
    color: blue;
    text-decoration: underline;
  }
  </style>
  