Commit ca3130a5 authored by Sébastien Chopin's avatar Sébastien Chopin

fix: Fix link on item page

parent ff8c3788
<template> <template>
<div class="item-view view"> <div class="item-view view">
<div class="item-view-header"> <div class="item-view-header">
<a :href="item.url" target="_blank"> <template v-if="isAbsolute(item.url)">
<a :href="item.url" target="_blank" rel="noopener"><h1 v-text="item.title" /></a>
<span class="host"> ({{ item.url | host }})</span>
</template>
<template v-else>
<h1 v-text="item.title" /> <h1 v-text="item.title" />
</a> </template>
<span v-if="item.url" class="host">
({{ item.url | host }})
</span>
<p class="meta"> <p class="meta">
{{ item.points }} points | by {{ item.points }} points | by
<router-link :to="'/user/' + item.user"> <router-link :to="'/user/' + item.user">
...@@ -53,6 +54,12 @@ export default { ...@@ -53,6 +54,12 @@ export default {
fetch({ store, params: { id } }) { fetch({ store, params: { id } }) {
return store.dispatch('FETCH_ITEM', { id }) return store.dispatch('FETCH_ITEM', { id })
},
methods: {
isAbsolute(url) {
return /^https?:\/\//.test(url)
}
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment