mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
feat: Added youtube video component
This commit is contained in:
@@ -2,9 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<section class='video-top-section video-section-bg'>
|
<section class='video-top-section video-section-bg'>
|
||||||
<div>
|
<div>
|
||||||
<div class="embed-responsive embed-responsive-16by9">
|
<youtube-player :url="contentData.url"/>
|
||||||
<iframe class="embed-responsive-item" :src="'https://www.youtube.com/embed/' + videoID" allowfullscreen></iframe>
|
|
||||||
</div>
|
|
||||||
<div class="mt-3 row">
|
<div class="mt-3 row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<h2>{{ contentData.name }}</h2>
|
<h2>{{ contentData.name }}</h2>
|
||||||
@@ -37,19 +35,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import YoutubePlayer from './YoutubePlayer.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['content', 'type'],
|
props: ['content', 'type'],
|
||||||
name: 'Video',
|
name: 'Video',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
contentData: '',
|
contentData: '',
|
||||||
videoID: '',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
YoutubePlayer
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getContent()
|
this.getContent()
|
||||||
.then(data => this.contentData = data)
|
.then(data => this.contentData = data)
|
||||||
.then((contentData) => this.videoID = this.getVideoID(this.contentData.url))
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getContent() {
|
getContent() {
|
||||||
@@ -57,19 +58,6 @@ export default {
|
|||||||
type: this.type,
|
type: this.type,
|
||||||
content: this.content
|
content: this.content
|
||||||
})
|
})
|
||||||
},
|
|
||||||
getVideoID(link) {
|
|
||||||
if (!Array.prototype.last){
|
|
||||||
Array.prototype.last = function(){
|
|
||||||
return this[this.length - 1];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
if (link.includes('v=')){
|
|
||||||
return link.split('v=')[1].split('&')[0]
|
|
||||||
}
|
|
||||||
else if (link.includes('youtu.be')) {
|
|
||||||
return link.split('/').last().split('?')[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user