Jumbotron.vue 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <div class="jumbotron">
  3. <div class="container">
  4. <h1 class="display-4" v-if="title">{{title}}</h1>
  5. <p class="lead">{{lead}}</p>
  6. <template v-if="link">
  7. <RouterLink
  8. v-if="!isExternal(link)"
  9. class="btn btn-primary btn-lg"
  10. :to="link"
  11. >
  12. {{linkLabel}}
  13. </RouterLink>
  14. <a class="btn btn-primary btn-lg" :href="link" role="button" target="_blank" v-else>
  15. {{linkLabel}}
  16. <OutboundLink />
  17. </a>
  18. </template>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import { isExternal } from '@theme/utils/index.js'
  24. export default {
  25. name: 'Jumbotron',
  26. props: {
  27. title: String,
  28. lead: String,
  29. link: String,
  30. linkLabel: String,
  31. backImage: String,
  32. },
  33. watch: {
  34. 'backImage': {
  35. handler (newVal) {
  36. if (newVal) {
  37. this.setBackImage(newVal)
  38. }
  39. }
  40. }
  41. },
  42. mounted() {
  43. this.setBackImage(this.backImage)
  44. },
  45. methods: {
  46. isExternal,
  47. setBackImage(img) {
  48. if (img && this.$el) {
  49. this.$el.style.backgroundImage = `url(${img})`
  50. }
  51. }
  52. }
  53. }
  54. </script>