Skip to content

Commit

Permalink
chore: add carbon ad tag
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed May 7, 2022
1 parent 4e4af30 commit 679efc5
Show file tree
Hide file tree
Showing 6 changed files with 577 additions and 12 deletions.
102 changes: 95 additions & 7 deletions packages/antd/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,41 @@ export default {
href: 'https://unpkg.com/antd/dist/antd.css',
},
],
headScripts: [
`
function loadAd(){
var header = document.querySelector('.__dumi-default-layout-content .markdown h1')
if(header && !header.querySelector('#_carbonads_js')){
var script = document.createElement('script')
script.src = '//cdn.carbonads.com/carbon.js?serve=CEAICK3M&placement=formilyjsorg'
script.id = '_carbonads_js'
script.classList.add('head-ad')
header.appendChild(script)
}
}
var request = null
var observer = new MutationObserver(function(){
cancelIdleCallback(request)
request = requestIdleCallback(loadAd)
})
document.addEventListener('DOMContentLoaded',function(){
loadAd()
observer.observe(
document.body,
{
childList:true,
subtree:true
}
)
})
`,
],
styles: [
`.__dumi-default-navbar-logo{
background-size: 140px!important;
background-position: center left!important;
background-repeat: no-repeat!important;
padding-left: 150px!important;/*可根据title的宽度调整*/
font-size: 22px!important;
color: #000!important;
font-weight: lighter!important;
height: 60px !important;
width: 150px !important;
padding-left:0 !important;
color: transparent !important;
}
.__dumi-default-navbar{
padding: 0 28px !important;
Expand All @@ -77,6 +103,68 @@ export default {
nav a{
text-decoration: none !important;
}
#carbonads * {
margin: initial;
padding: initial;
}
#carbonads {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial,
sans-serif;
}
#carbonads {
display: flex;
max-width: 330px;
background-color: hsl(0, 0%, 98%);
box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, 0.1);
z-index: 100;
float:right;
}
#carbonads a {
color: inherit;
text-decoration: none;
}
#carbonads a:hover {
color: inherit;
}
#carbonads span {
position: relative;
display: block;
overflow: hidden;
}
#carbonads .carbon-wrap {
display: flex;
}
#carbonads .carbon-img {
display: block;
margin: 0;
line-height: 1;
}
#carbonads .carbon-img img {
display: block;
}
#carbonads .carbon-text {
font-size: 13px;
padding: 10px;
margin-bottom: 16px;
line-height: 1.5;
text-align: left;
}
#carbonads .carbon-poweredby {
display: block;
padding: 6px 8px;
background: #f1f1f2;
text-align: center;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 600;
font-size: 8px;
line-height: 1;
border-top-left-radius: 3px;
position: absolute;
bottom: 0;
right: 0;
}
`,
],
}
91 changes: 91 additions & 0 deletions packages/core/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,35 @@ export default {
},
],
},
headScripts: [
`
function loadAd(){
var header = document.querySelector('.__dumi-default-layout-content .markdown h1')
if(header && !header.querySelector('#_carbonads_js')){
var script = document.createElement('script')
script.src = '//cdn.carbonads.com/carbon.js?serve=CEAICK3M&placement=formilyjsorg'
script.id = '_carbonads_js'
script.classList.add('head-ad')
header.appendChild(script)
}
}
var request = null
var observer = new MutationObserver(function(){
cancelIdleCallback(request)
request = requestIdleCallback(loadAd)
})
document.addEventListener('DOMContentLoaded',function(){
loadAd()
observer.observe(
document.body,
{
childList:true,
subtree:true
}
)
})
`,
],
styles: [
`.__dumi-default-navbar-logo{
background-size: 140px!important;
Expand Down Expand Up @@ -75,6 +104,68 @@ export default {
nav a{
text-decoration: none !important;
}
#carbonads * {
margin: initial;
padding: initial;
}
#carbonads {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial,
sans-serif;
}
#carbonads {
display: flex;
max-width: 330px;
background-color: hsl(0, 0%, 98%);
box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, 0.1);
z-index: 100;
float:right;
}
#carbonads a {
color: inherit;
text-decoration: none;
}
#carbonads a:hover {
color: inherit;
}
#carbonads span {
position: relative;
display: block;
overflow: hidden;
}
#carbonads .carbon-wrap {
display: flex;
}
#carbonads .carbon-img {
display: block;
margin: 0;
line-height: 1;
}
#carbonads .carbon-img img {
display: block;
}
#carbonads .carbon-text {
font-size: 13px;
padding: 10px;
margin-bottom: 16px;
line-height: 1.5;
text-align: left;
}
#carbonads .carbon-poweredby {
display: block;
padding: 6px 8px;
background: #f1f1f2;
text-align: center;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 600;
font-size: 8px;
line-height: 1;
border-top-left-radius: 3px;
position: absolute;
bottom: 0;
right: 0;
}
`,
],
menus: {
Expand Down
91 changes: 91 additions & 0 deletions packages/next/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,35 @@ export default {
href: 'https://unpkg.com/@alifd/next/dist/next-noreset.css',
},
],
headScripts: [
`
function loadAd(){
var header = document.querySelector('.__dumi-default-layout-content .markdown h1')
if(header && !header.querySelector('#_carbonads_js')){
var script = document.createElement('script')
script.src = '//cdn.carbonads.com/carbon.js?serve=CEAICK3M&placement=formilyjsorg'
script.id = '_carbonads_js'
script.classList.add('head-ad')
header.appendChild(script)
}
}
var request = null
var observer = new MutationObserver(function(){
cancelIdleCallback(request)
request = requestIdleCallback(loadAd)
})
document.addEventListener('DOMContentLoaded',function(){
loadAd()
observer.observe(
document.body,
{
childList:true,
subtree:true
}
)
})
`,
],
styles: [
`.__dumi-default-navbar-logo{
background-size: 140px!important;
Expand Down Expand Up @@ -73,6 +102,68 @@ export default {
nav a{
text-decoration: none !important;
}
#carbonads * {
margin: initial;
padding: initial;
}
#carbonads {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial,
sans-serif;
}
#carbonads {
display: flex;
max-width: 330px;
background-color: hsl(0, 0%, 98%);
box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, 0.1);
z-index: 100;
float:right;
}
#carbonads a {
color: inherit;
text-decoration: none;
}
#carbonads a:hover {
color: inherit;
}
#carbonads span {
position: relative;
display: block;
overflow: hidden;
}
#carbonads .carbon-wrap {
display: flex;
}
#carbonads .carbon-img {
display: block;
margin: 0;
line-height: 1;
}
#carbonads .carbon-img img {
display: block;
}
#carbonads .carbon-text {
font-size: 13px;
padding: 10px;
margin-bottom: 16px;
line-height: 1.5;
text-align: left;
}
#carbonads .carbon-poweredby {
display: block;
padding: 6px 8px;
background: #f1f1f2;
text-align: center;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 600;
font-size: 8px;
line-height: 1;
border-top-left-radius: 3px;
position: absolute;
bottom: 0;
right: 0;
}
`,
],
}
Loading

0 comments on commit 679efc5

Please sign in to comment.