Skip to content

Commit

Permalink
fix(carbon): add format argument
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <[email protected]>
  • Loading branch information
ZTL-UwU committed Nov 9, 2024
1 parent 3a8a454 commit 19d512a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 30 deletions.
3 changes: 2 additions & 1 deletion app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ export default defineAppConfig({
target: '_blank',
}],
carbonAds: {
enable: false,
enable: true,
code: '',
placement: '',
format: 'cover',
},
},
search: {
Expand Down
37 changes: 11 additions & 26 deletions components/layout/CarbonAds.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<!-- Ported from Vitepress -->
<template>
<div
ref="container"
class="carbon-ads my-6 flex min-h-[260px] items-center justify-center rounded-lg border p-4 text-center"
/>
<div ref="container" class="mt-6" />
</template>

<script setup lang="ts">
Expand All @@ -18,7 +15,7 @@ function init() {
const s = document.createElement('script');
s.type = 'text/javascript';
s.id = '_carbonads_js';
s.src = `//cdn.carbonads.com/carbon.js?serve=${carbonAds.code}&placement=${carbonAds.placement}`;
s.src = `//cdn.carbonads.com/carbon.js?serve=${carbonAds.code}&placement=${carbonAds.placement}&format=${carbonAds.format}`;
s.async = true;
container.value.appendChild(s);
}
Expand All @@ -37,32 +34,20 @@ if (carbonAds.enable) {
}
</script>

<style scoped>
.carbon-ads {
@apply leading-4 text-xs font-medium;
<style>
.carbon-responsive-wrap {
@apply bg-background border-border px-4 py-6 rounded-lg flex flex-col items-center !important;
}

.carbon-ads :deep(img) {
@apply mx-auto my-0 rounded-md;
.carbon-responsive-wrap .carbon-img {
@apply flex-none rounded overflow-hidden !important;
}

.carbon-ads :deep(.carbon-text) {
@apply block mx-auto my-0 text-sm font-medium pt-4 hover:text-primary transition-colors;
.carbon-responsive-wrap .carbon-text {
@apply text-muted-foreground text-sm flex-none text-center !important;
}

.carbon-ads :deep(.carbon-poweredby) {
@apply block pt-3 text-[11px] uppercase text-muted-foreground;
}

.carbon-ads :deep(.carbon-poweredby:hover) {
@apply text-muted-foreground;
}

.carbon-ads :deep(> div) {
@apply hidden;
}

.carbon-ads :deep(> div:first-of-type) {
@apply block;
#carbonads .carbon-poweredby {
@apply bg-background text-muted-foreground block text-right text-[10px] uppercase no-underline !important;
}
</style>
1 change: 1 addition & 0 deletions composables/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const defaultConfig: DefaultConfig = {
enable: false,
code: '',
placement: '',
format: 'cover',
},
},
search: {
Expand Down
4 changes: 4 additions & 0 deletions content/3.api/1.configuration/1.shadcn-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ All configurable icons can be set to iconify icons, emojis and urls, using [smar
::field{name="placement" type="string"}
Carbon Ads placement.
::
::field{name="format" type="'cover' | 'responsive'" default-value="cover"}
Carbon Ads format.
::
::
::
::
Expand Down Expand Up @@ -317,6 +320,7 @@ const defaultConfig: DefaultConfig = {
enable: false,
code: '',
placement: '',
format: 'cover',
},
},
search: {
Expand Down
3 changes: 2 additions & 1 deletion content/3.api/1.configuration/4.carbon-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export default defineAppConfig({
carbonAds: {
enabled: true,
code: 'your-carbon-code',
placement: 'your-carbon-placement'
placement: 'your-carbon-placement',
format: 'your-carbon-format', // defaults to 'cover'
},
}
},
Expand Down
2 changes: 1 addition & 1 deletion content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ navigation: false
::hero
---
announcement:
title: 'Release v0.7.3'
title: 'Release v0.7.4'
icon: '🎉'
to: https://github.com/ZTL-UwU/shadcn-docs-nuxt/releases
target: _blank
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "shadcn-docs-nuxt",
"type": "module",
"version": "0.7.3",
"version": "0.7.4",
"description": "Effortless and beautiful docs template built with Nuxt Content & shadcn-vue.",
"author": "Tony Zhang <[email protected]>",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface DefaultConfig {
enable: boolean;
code: string;
placement: string;
format: 'cover' | 'responsive';
};
};
search: {
Expand Down

0 comments on commit 19d512a

Please sign in to comment.