@tsed/vitepress-theme
v1.3.0
Published
Shared components for vitepress
Downloads
1,088
Readme
Official Ts.ED theme for VitePress
Installation
yarn add @tsed/vitepress-theme
Configuration
In your config.mts file, you can import the theme and extend it:
// https://vitepress.dev/guide/custom-theme
import {DefaultTheme} from "@tsed/vitepress-theme";
import type {Theme} from "vitepress";
import {h} from "vue";
import HomeBanner from "@tsed/vitepress-theme/organisms/home/HomeBanner.vue";
import HomePartners from "@tsed/vitepress-theme/organisms/home/HomePartners.vue";
import HomeBody from "@tsed/vitepress-theme/organisms/home/HomeBody.vue";
import HomeTabsTerminal from "@tsed/vitepress-theme/organisms/home/terminal/HomeTabsTerminal.vue";
import HomeTabTerminalNpm from "@tsed/vitepress-theme/organisms/home/terminal/HomeTabTerminalNpm.vue";
import HomeTabTerminalYarn from "@tsed/vitepress-theme/organisms/home/terminal/HomeTabTerminalYarn.vue";
import HomeTabTerminalPnpm from "@tsed/vitepress-theme/organisms/home/terminal/HomeTabTerminalPnpm.vue";
import HomeTabTerminalBun from "@tsed/vitepress-theme/organisms/home/terminal/HomeTabTerminalBun.vue";
export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
"home-hero-image": () =>
h(HomeBanner, null, { // you can override the default theme banner by your own component
default: () =>
h(HomeTabsTerminal, null, {
npm: () => h(HomeTabTerminalNpm), // Replace the default NPM terminal tab
yarn: () => h(HomeTabTerminalYarn), // Replace the default Yarn terminal tab
pnpm: () => h(HomeTabTerminalPnpm), // Replace the default Pnpm terminal tab
bun: () => h(HomeTabTerminalBun) // Replace the default Bun terminal tab
})
}),
"home-features-before": () => h(HomePartners),
"home-features-after": () => h(HomeBody)
});
}
} satisfies Theme;
Then, create a tailwind.config.ts
configuration file:
import type {Config} from "tailwindcss";
import {tailwindPreset} from "@tsed/vitepress-theme/tailwind.preset";
const config = {
presets: [tailwindPreset as unknown as Config],
darkMode: "class",
content: [
"./docs/.vitepress/**/*.{js,ts,vue}",
"./docs/.vitepress/themes/**/*.{js,ts,vue}",
"./packages/theme/**/*.{js,ts,vue}",
"./docs/**/*.md"
],
safelist: [
{pattern: /^bg-/},
{pattern: /^text-/},
{pattern: /^m-/},
{pattern: /^mx-/},
{pattern: /^p-/},
{pattern: /^px-/},
{pattern: /^gap-/},
{pattern: /^shadow-/}
]
} satisfies Config;
export default config;
Implement your own Npm/Yarn/Pnpm/Bun terminal tab
You can implement your own terminal tab by creating a new component as follows:
<template>
<pre
class="shiki shiki-themes github-light github-dark vp-code"
tabindex="0"
><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">npx</span><span
style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -p</span><span
style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> @tsed/cli</span><span
style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> tsed</span><span
style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> init</span><span
style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> .</span></span></code></pre>
</template>
Then, you can import it in your config.mts
file:
import {DefaultTheme} from "@tsed/vitepress-theme";
import type {Theme} from "vitepress";
import {h} from "vue";
import HomeBanner from "@tsed/vitepress-theme/organisms/home/HomeBanner.vue";
import HomePartners from "@tsed/vitepress-theme/organisms/home/HomePartners.vue";
import HomeBody from "@tsed/vitepress-theme/organisms/home/HomeBody.vue";
import HomeTabsTerminal from "@tsed/vitepress-theme/organisms/home/terminal/HomeTabsTerminal.vue";
import HomeTabTerminalNpm from "./terminal/HomeTabTerminalNpm.vue";
import HomeTabTerminalYarn from "./terminal/HomeTabTerminalYarn.vue";
import HomeTabTerminalPnpm from "./terminal/HomeTabTerminalPnpm.vue";
import HomeTabTerminalBun from "./terminal/HomeTabTerminalBun.vue";
export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
"home-hero-image": () =>
h(HomeBanner, null, {
default: () =>
h(HomeTabsTerminal, null, {
npm: () => h(HomeTabTerminalNpm),
yarn: () => h(HomeTabTerminalYarn),
pnpm: () => h(HomeTabTerminalPnpm),
bun: () => h(HomeTabTerminalBun)
})
}),
"home-features-before": () => h(HomePartners),
"home-features-after": () => h(HomeBody)
});
}
} satisfies Theme;
Contributors
Please read contributing guidelines here.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
License
The MIT License (MIT)
Copyright (c) 2016 - 2023 Romain Lenzotti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.