<commit_before><template>
  <section class="post-view">
    <div v-if="!content"></div>
    <h1 class="post-title">
      {{ title }}
      <time pubdate="pubdate" :datetime="this.date | formatDate" :title="this.date | formatDate" class="post-date">{{ this.date | timeago }}</time>
    </h1>
    <article v-if="content" v-html="htmlFromMarkdown"></article>
  </section>
</template>

<script>
import Vue from 'vue'
import api from '../api'
import config from '../config.json'
import fm from 'front-matter'
import marked from '../utils/render.js'

export default {
  name: 'postView',

  data() {
    return { title: '', date: null, content: '' }
  },

  computed: {
    htmlFromMarkdown() { return marked(this.content) }
  },

  methods: {
    loadPost() {
      api.getDetail(this.$route.params.hash)
        .then(txt => {
          const content = fm(txt)
          this.content = content.body
          this.title = content.attributes.title
          this.date = contnt.attributes.date
          // Set window title
          window.document.title = `${this.title} - ${config.blogName}`
        })
        .catch(e => { console.error(e) })
    },

    newTab() {
      Vue.nextTick(() => {
        // Load the external link into new tab
        const linksArr = Array.from(document.querySelectorAll('a'))
        const currHost = window.location.host
        linksArr.map(el => {
          if (el.href && el.host !== currHost) {
            el.target = '_blank'
            el.rel = 'noopener noreferrer'
          }
        })
      })
    }<commit_msg>PostView API integration, and minor corrections<commit_after><template>
  <section class="post-view">
    <div v-if="!content">Loading ...</div>
    <h1 class="post-title">
      {{ title }}
      <time pubdate="pubdate" :datetime="this.date | formatDate" :title="this.date | formatDate" class="post-date">{{ this.date | timeago }}</time>
    </h1>
    <article v-if="content" v-html="htmlFromMarkdown"></article>
  </section>
</template>

<script>
import Vue from 'vue'
import api from '../api'
import config from '../config.json'
import fm from 'front-matter'
import marked from '../utils/render.js'

export default {
  name: 'postView',

  data() {
    return { title: '', date: null, content: '' }
  },

  computed: {
    htmlFromMarkdown() { return marked(this.content) }
  },

  created () {
    this.loadPost()
  },

  methods: {
    loadPost() {
      api.getDetail(this.$route.params.hash)
        .then(txt => {
          const content = fm(txt)
          this.content = content.body
          this.title = content.attributes.title
          this.date = content.attributes.date
          // Set window title
          window.document.title = `${this.title} - ${config.blogName}`
        })
        .catch(e => { console.error(e) })
    },

    newTab() {
      Vue.nextTick(() => {
        // Load the external link into new tab
        const linksArr = Array.from(document.querySelectorAll('a'))
        const currHost = window.location.host
        linksArr.map(el => {
          if (el.href && el.host !== currHost) {
            el.target = '_blank'
            el.rel = 'noopener noreferrer'
          }
        })
      })
    }
{'fraction_non_alphanumeric': 0.16244923461418306, 'fraction_numerical': 0.0012496094970321774, 'mean_word_length': 2.277379733879222, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5173077', 'n_tokens_mistral': 998, 'n_tokens_neox': 991, 'n_words': 218}