Skip to content

Commit

Permalink
Merge branch 'master' of github.com:DIYgod/DPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Jun 1, 2022
2 parents 92882bf + ba61ce3 commit 6017996
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = {
['script', { src: 'https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js' }],
['script', { src: 'https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js' }],
],
theme: 'vuepress-theme-dplayer',
themeConfig: {
repo: 'MoePlayer/DPlayer',
editLinks: true,
Expand Down
65 changes: 65 additions & 0 deletions docs/.vuepress/theme/components/CarbonAds.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script>
export default {
name: 'CarbonAds',
watch: {
'$route' (to, from) {
if (
to.path !== from.path
// Only reload if the ad has been loaded
// otherwise it's possible that the script is appended but
// the ads are not loaded yet. This would result in duplicated ads.
&& this.$el.querySelector('#carbonads')
) {
this.$el.innerHTML = ''
this.load()
}
}
},
mounted () {
this.load()
},
methods: {
load () {
const s = document.createElement('script')
s.id = '_carbonads_js'
s.src = `//cdn.carbonads.com/carbon.js?serve=CEAI6277&placement=dplayerjsorg`
this.$el.appendChild(s)
}
},
render (h) {
return h('div', { class: 'carbon-ads' })
}
}
</script>

<style lang="stylus">
.carbon-ads
min-height 102px
padding 1.5rem 1.5rem 0
margin-bottom -0.5rem
font-size 0.75rem
a
color #444
font-weight normal
display inline
.carbon-img
float left
margin-right 1rem
border 1px solid $borderColor
img
display block
.carbon-poweredby
color #999
display block
margin-top 0.5em
@media (max-width: $MQMobile)
.carbon-ads
.carbon-img img
width 100px
height 77px
</style>
3 changes: 3 additions & 0 deletions docs/.vuepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extend: '@vuepress/theme-default',
};
21 changes: 21 additions & 0 deletions docs/.vuepress/theme/layouts/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<ParentLayout>
<template #sidebar-top>
<CarbonAds />
</template>
</ParentLayout>
</template>

<script>
import ParentLayout from '@parent-theme/layouts/Layout.vue'
import CarbonAds from '@theme/components/CarbonAds.vue'
export default {
name: 'Layout',
components: {
ParentLayout,
CarbonAds,
}
}
</script>
4 changes: 4 additions & 0 deletions docs/.vuepress/theme/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "vuepress-theme-dplayer",
"main": "index.js"
}

0 comments on commit 6017996

Please sign in to comment.