docs: add carbon ads

This commit is contained in:
DIYgod 2022-04-29 10:55:17 +01:00
parent 4e65978b0c
commit 5d3692384e
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
5 changed files with 94 additions and 0 deletions

View File

@ -67,6 +67,7 @@ module.exports = {
['link', { rel: 'apple-touch-icon', href: '/apple-touch-icon.png' }],
['link', { rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#ff8549' }],
],
theme: 'vuepress-theme-rsshub',
themeConfig: {
repo: 'DIYgod/RSSHub',
editLinks: true,

View File

@ -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=CEAI653E&placement=docsrsshubapp`
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>

View File

@ -0,0 +1,3 @@
module.exports = {
extend: '@vuepress/theme-default',
};

View File

@ -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>

View File

@ -0,0 +1,4 @@
{
"name": "vuepress-theme-rsshub",
"main": "index.js"
}