介绍
传递 theme 选项至 sveltepress 来使用一个主题
阅读 Vite 插件选项参考 来获得更多信息
| 选择 | 适用场景 | 内容模型 | 搜索 |
|---|---|---|---|
| 默认主题 | 文档、产品指南和 API 参考 | 使用 Markdown 或 Svelte 编写的 SvelteKit 路由 | Algolia DocSearch,或通过自定义包装组件接入 Meilisearch(见生产构建限制) |
| 博客主题 | 编辑型站点和按时间发布的内容 | src/posts 中的 Markdown 与自动生成路由 | 内置 Pagefind |
默认主题
安装
npm install --save @sveltepress/theme-default sh
yarn add @sveltepress/theme-default sh
pnpm install @sveltepress/theme-default sh
bun add @sveltepress/theme-default sh
在 vite.config.(js|ts) 中配置
vite.config.(js|ts)
+
-
+
+
+
import { const defaultTheme: ThemeDefaultdefaultTheme } from '@sveltepress/theme-default'
import { const sveltepress: (options?: SveltepressVitePluginOptions) => PluginOptionsveltepress } from '@sveltepress/vite'
import { function defineConfig(config: UserConfig): UserConfig (+5 overloads)Type helper to make it easier to use vite.config.ts
accepts a direct
UserConfig
object, or a function that returns it.
The function receives a
ConfigEnv
object.
defineConfig } from 'vite'
const const config: UserConfigconfig = function defineConfig(config: UserConfig): UserConfig (+5 overloads)Type helper to make it easier to use vite.config.ts
accepts a direct
UserConfig
object, or a function that returns it.
The function receives a
ConfigEnv
object.
defineConfig({
UserConfig.plugins?: PluginOption[] | undefinedArray of vite plugins to use.
plugins: [
function sveltepress(options?: SveltepressVitePluginOptions): PluginOptionsveltepress(),
function sveltepress(options?: SveltepressVitePluginOptions): PluginOptionsveltepress({
SveltepressVitePluginOptions.theme?: ResolvedTheme | undefinedtheme: function defaultTheme(themeOptions?: DefaultThemeOptions | undefined): ResolvedThemedefaultTheme(/** theme options */)
})
],
})
export default const config: UserConfigconfig ts
阅读默认主题参考来获得更多信息
博客主题
博客主题提供文章索引、分页、标签、分类、RSS、Open Graph 图片、相关文章、评论和 Pagefind 搜索界面。它生成静态站点,当前需要 @sveltejs/adapter-static,并在 Vite 构建后运行 Pagefind。
从博客主题快速上手开始,并把在线 Demo作为可运行参考。