Skip to content

Commit

Permalink
Add source link to public page
Browse files Browse the repository at this point in the history
  • Loading branch information
karlomikus committed Dec 30, 2023
1 parent 69d08bb commit 17b68cb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Cocktail/CocktailPublicDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<PublicRecipe :cocktail="cocktail"></PublicRecipe>
<div class="public-footer">
Powered by <a href="https://barassistant.app">Bar Assistant</a>
<template v-if="cocktail.source">
&middot; <SourcePresenter :source="cocktail.source"></SourcePresenter>
</template>
<!-- &middot; <a href="#">Add to your bar</a> &middot; <a href="#">Print</a> -->
</div>
</div>
Expand All @@ -15,11 +18,13 @@
import ApiRequests from '@/ApiRequests'
import SiteLogo from '@/components/Layout/SiteLogo.vue'
import PublicRecipe from '@/components/Cocktail/PublicRecipe.vue'
import SourcePresenter from '../SourcePresenter.vue'
export default {
components: {
SiteLogo,
PublicRecipe
PublicRecipe,
SourcePresenter
},
data() {
return {
Expand Down
28 changes: 28 additions & 0 deletions src/components/SourcePresenter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<a :href="source" v-if="isLink" target="_blank">{{ $t('source') }}</a>
<span v-else>{{ $t('source') }}: {{ source }}</span>
</template>

<script>
export default {
props: {
source: {
type: String,
default: null,
}
},
computed: {
isLink() {
let url;
try {
url = new URL(this.source);
} catch (_) {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
}
}
}
</script>

0 comments on commit 17b68cb

Please sign in to comment.