Skip to content

Instantly share code, notes, and snippets.

@TravisMullen
Created August 5, 2017 16:45
Show Gist options
  • Save TravisMullen/1fc33542b866c027e5ffafc530f37a54 to your computer and use it in GitHub Desktop.
Save TravisMullen/1fc33542b866c027e5ffafc530f37a54 to your computer and use it in GitHub Desktop.
<template lang="pug">
a.button.icon-link(
target='_blank',
:href='route',
:title='title'
)
.svg-icon.small.fill-cream(
v-once='',
v-html='icon'
)
</template>
<script>
// REQUIRED: npm install svg-inline-loader pug --save-dev
export default {
name: 'icon-link',
props: {
// name of file from `/src/assets/svg/*`
iconName: {
type: String,
required: true
},
// text inside button
title: {
type: String,
required: true
},
// named route for `vuejs/vue-router`
// https://router.vuejs.org/en/essentials/named-routes.html
route: {
type: String,
required: true
}
},
computed: {
icon () {
const file = require(`!svg-inline-loader!@/assets/icons/${this.iconName}.svg`)
return file
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment