Better self link detection
This commit is contained in:
parent
1d62d2924e
commit
9cf42d8b33
3 changed files with 15 additions and 33 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<component :is="hasRoute ? 'router-link' : 'a'" class="xlcxczvw _link" :[attr]="hasRoute ? url.substr(local.length) : url" :rel="rel" :target="target"
|
<component :is="self ? 'router-link' : 'a'" class="xlcxczvw _link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target"
|
||||||
@mouseover="onMouseover"
|
@mouseover="onMouseover"
|
||||||
@mouseleave="onMouseleave"
|
@mouseleave="onMouseleave"
|
||||||
:title="url"
|
:title="url"
|
||||||
|
@ -27,18 +27,12 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const isSelf = this.url.startsWith(local);
|
const self = this.url.startsWith(local);
|
||||||
const hasRoute = isSelf && (
|
|
||||||
(this.url.substr(local.length) === '/') ||
|
|
||||||
this.url.substr(local.length).startsWith('/@') ||
|
|
||||||
this.url.substr(local.length).startsWith('/notes/') ||
|
|
||||||
this.url.substr(local.length).startsWith('/tags/'));
|
|
||||||
return {
|
return {
|
||||||
local,
|
local,
|
||||||
self: isSelf,
|
self: self,
|
||||||
hasRoute: hasRoute,
|
attr: self ? 'to' : 'href',
|
||||||
attr: hasRoute ? 'to' : 'href',
|
target: self ? null : '_blank',
|
||||||
target: hasRoute ? null : '_blank',
|
|
||||||
showTimer: null,
|
showTimer: null,
|
||||||
hideTimer: null,
|
hideTimer: null,
|
||||||
preview: null,
|
preview: null,
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="mk-url-preview" v-size="[{ max: 400 }, { max: 350 }]">
|
<div v-else class="mk-url-preview" v-size="[{ max: 400 }, { max: 350 }]">
|
||||||
<transition name="zoom" mode="out-in">
|
<transition name="zoom" mode="out-in">
|
||||||
<component :is="hasRoute ? 'router-link' : 'a'" :class="{ compact }" :[attr]="hasRoute ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url" v-if="!fetching">
|
<component :is="self ? 'router-link' : 'a'" :class="{ compact }" :[attr]="self ? url.substr(local.length) : url" rel="nofollow noopener" :target="target" :title="url" v-if="!fetching">
|
||||||
<div class="thumbnail" v-if="thumbnail" :style="`background-image: url('${thumbnail}')`">
|
<div class="thumbnail" v-if="thumbnail" :style="`background-image: url('${thumbnail}')`">
|
||||||
<button class="_button" v-if="!playerEnabled && player.url" @click.prevent="playerEnabled = true" :title="$t('enable-player')"><fa :icon="faPlayCircle"/></button>
|
<button class="_button" v-if="!playerEnabled && player.url" @click.prevent="playerEnabled = true" :title="$t('enable-player')"><fa :icon="faPlayCircle"/></button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,12 +58,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
const isSelf = this.url.startsWith(local);
|
const self = this.url.startsWith(local);
|
||||||
const hasRoute =
|
|
||||||
(this.url.substr(local.length) === '/') ||
|
|
||||||
this.url.substr(local.length).startsWith('/@') ||
|
|
||||||
this.url.substr(local.length).startsWith('/notes/') ||
|
|
||||||
this.url.substr(local.length).startsWith('/tags/');
|
|
||||||
return {
|
return {
|
||||||
local,
|
local,
|
||||||
fetching: true,
|
fetching: true,
|
||||||
|
@ -79,10 +74,9 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
tweetUrl: null,
|
tweetUrl: null,
|
||||||
playerEnabled: false,
|
playerEnabled: false,
|
||||||
self: isSelf,
|
self: self,
|
||||||
hasRoute: hasRoute,
|
attr: self ? 'to' : 'href',
|
||||||
attr: hasRoute ? 'to' : 'href',
|
target: self ? null : '_blank',
|
||||||
target: hasRoute ? null : '_blank',
|
|
||||||
faPlayCircle
|
faPlayCircle
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<component :is="hasRoute ? 'router-link' : 'a'" class="ieqqeuvs _link" :[attr]="hasRoute ? url.substr(local.length) : url" :rel="rel" :target="target"
|
<component :is="self ? 'router-link' : 'a'" class="ieqqeuvs _link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target"
|
||||||
@mouseover="onMouseover"
|
@mouseover="onMouseover"
|
||||||
@mouseleave="onMouseleave"
|
@mouseleave="onMouseleave"
|
||||||
>
|
>
|
||||||
|
@ -37,12 +37,7 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const isSelf = this.url.startsWith(local);
|
const self = this.url.startsWith(local);
|
||||||
const hasRoute = isSelf && (
|
|
||||||
(this.url.substr(local.length) === '/') ||
|
|
||||||
this.url.substr(local.length).startsWith('/@') ||
|
|
||||||
this.url.substr(local.length).startsWith('/notes/') ||
|
|
||||||
this.url.substr(local.length).startsWith('/tags/'));
|
|
||||||
return {
|
return {
|
||||||
local,
|
local,
|
||||||
schema: null as string | null,
|
schema: null as string | null,
|
||||||
|
@ -51,10 +46,9 @@ export default Vue.extend({
|
||||||
pathname: null as string | null,
|
pathname: null as string | null,
|
||||||
query: null as string | null,
|
query: null as string | null,
|
||||||
hash: null as string | null,
|
hash: null as string | null,
|
||||||
self: isSelf,
|
self: self,
|
||||||
hasRoute: hasRoute,
|
attr: self ? 'to' : 'href',
|
||||||
attr: hasRoute ? 'to' : 'href',
|
target: self ? null : '_blank',
|
||||||
target: hasRoute ? null : '_blank',
|
|
||||||
showTimer: null,
|
showTimer: null,
|
||||||
hideTimer: null,
|
hideTimer: null,
|
||||||
preview: null,
|
preview: null,
|
||||||
|
|
Loading…
Reference in a new issue