Vite প্লাগিন

এক নজরে Types

import type {  } from '@sveltejs/kit/vite'
import type {  } from 'shiki/langs'
import type {  } from 'unified'
import type {  } from 'vite'

/**
 * The options accepted by SvelteKit's `sveltekit()` vite plugin.
 *
 * On the newer SvelteKit project layout there is no `svelte.config.js` and all
 * config (`compilerOptions`, `adapter`, ...) is passed inline to `sveltekit()`
 * in `vite.config.ts`. Forward those options through `sveltepress()` so the
 * standalone `sveltekit()` plugin can be removed (having both crashes the dev
 * server with duplicated Svelte compilation).
 */
export type  = <typeof >[0]

export type  = <[], any>

export type  = (: string, : , ?: string) => string | <string>

export type  = [] | ((: ) => <[]>) | ((: ) => [])

export interface SiteConfig {
  ?: string
  ?: string
}
export interface ResolvedTheme {
  : string
  : string
  : string
  : 
  : 
  ?: []
  ?: []
  /**
   * The footnote label used for [remark rehype](https://github.com/remarkjs/remark-rehype#api)
   */
  ?: string
  /** Receive the core version configuration before theme plugins are resolved. */
  ?: (: ) => void
}

export type  = SveltepressVitePluginOptions['versions']

export type  = ((: []) => [])

export type  = ((: []) => [])

export interface PageInfo {
  : string
  : string
  : string
  : <string, unknown>
}

/**
 * A single locale of a multi-locale site. Keyed by its URL prefix (`'/'` for
 * the default locale, `'/zh/'`, `'/bn/'`, ...).
 */
export interface < = any> {
  /** BCP 47 language tag, e.g. `'en'`, `'zh-CN'`, `'bn'`. */
  : string
  /** User-facing label rendered in the language switcher. */
  : string
  /** The locale's full theme options. */
  : 
  /**
   * Logical routes available in this locale (no locale prefix). Populated by
   * the core plugin from the routes directory; only needed explicitly when
   * constructing configs directly.
   */
  ?: string[]
}

/** Multi-locale site configuration keyed by URL prefix. */
export type < = any> = <string, <>>

/** A locale resolved from a route: the locale config plus its matched prefix. */
export interface < = any> extends <> {
  /** The locale's URL prefix, e.g. `'/'`, `'/zh/'`. */
  : string
}

/** The target of a locale switch. */
export interface LocaleSwitchTarget {
  : string
  /** Whether the target locale lacks the logical page and the href falls back to its home. */
  : boolean
}

/**
 * Slim per-locale version snapshot used by the language switcher. Only the
 * fields needed to keep the same frozen version (and fall back otherwise)
 * are required; full manifests stay on `virtual:sveltepress/versions`.
 */
export interface LocaleVersionSnapshot {
  : string
  : { : string, ?: string[] }
  : <{ : string, ?: string[] }>
}

export interface LlmsConfig {
  ?: boolean
  ?: string
  ?: string
  ?: string
  ?: string
  ?: (: string, : <string, unknown>) => boolean
  ?: (: PageInfo, : PageInfo) => number
}

export interface SveltepressVitePluginOptions {
  ?: ResolvedTheme
  ?: SiteConfig
  ?: boolean
  ?: [] | 
  ?: [] | 
  ?: LlmsConfig
  /**
   * Multi-locale site configuration keyed by URL prefix (`'/'` for the default
   * locale, `'/zh/'`, `'/bn/'`, ...). Each entry carries that locale's `lang`,
   * a user-facing `label` for the switcher, and its full theme options.
   *
   * When omitted the site stays single-locale and behavior is unchanged.
   */
  ?: 
  /**
   * Enable document version management by discovering
   * `sveltepress.versions.json`, override its location, or disable discovery.
   */
  ?: false | {
    ?: string
  }
  /**
   * Options forwarded to the SvelteKit vite plugin that `sveltepress()` sets up
   * internally.
   *
   * Use this on the newer SvelteKit layout (no `svelte.config.js`, config passed
   * inline to `sveltekit()`) to move your `compilerOptions`, `adapter`, etc. into
   * `sveltepress()` and remove the standalone `sveltekit()` plugin. `'.md'` is
   * always added to `extensions` automatically.
   *
   * When omitted, SvelteKit reads its config from `svelte.config.js` as before.
   */
  ?: 
  /**
   * Options for Pagefind static local search indexing.
   * Set to `false` to disable automatic post-build indexing.
   */
  ?: boolean | import('./pagefind.js').PagefindOptions
}

export type < = any> = (?: ) => ResolvedTheme

export type  = <any[], any> | [<any[], any>, any]

export type  = <>
ts
Expand code

প্লাগিন অপশন

siteConfig

  • title: সাইটের টাইটেল। না থাকলে 'Untitled site' দেখাবে।
  • description: সাইটের ডেসক্রিপশন। না থাকলে 'Build by sveltepress' দেখাবে।

addInspect

যদি true সেট করা হয়, তাহলে Vite plugin inspect যোগ করা হবে। ভিট পাইপলাইন দেখা ও পর্যবেক্ষণ করা বেশ উপকারী।

theme

নিম্নে ResolvedTheme দেখুন

remarkPlugins

The remark plugins ব্যবহার করা হয়েছে মার্কডাউন এর জন্য। আরো জানতে Remark plugins পড়ুন।

rehypePlugins

The rehype plugins ব্যবহার করা হয়েছে html জেনারেট করার জন্য। আরো জানতে Rehype plugins পড়ুন।

llms

production build-এর সময় machine-readable documentation index তৈরি করে। ডিফল্টে বন্ধ থাকে।

vite.config.ts
import {  } from '@sveltepress/vite'

({
  : {
    : 'My docs',
    : 'Documentation for my project',
  },
  : {
    : true,
    : 'https://docs.example.com',
    : (, ) => . !== false,
  },
})
ts
OptionTypeDefaultকাজ
enabledbooleanfalsebuild-এর সময় llms.txtllms-full.txt লেখে।
titlestringsiteConfig.titleতৈরি হওয়া উভয় ফাইলের title।
descriptionstringsiteConfig.descriptionতৈরি হওয়া উভয় ফাইলের description।
baseUrlstring''route link-এর আগে যোগ হওয়া absolute site origin।
routesDirstring'src/routes'page scan করার directory।
filter(filePath, frontmatter) => booleanনির্বাচিত page বাদ দেয়।
sort(a, b) => numberroute pathpage order কাস্টমাইজ করে।

Generator শুধু Markdown page পড়ে; Svelte-only page ও runtime data অন্তর্ভুক্ত হয় না। Incremental document version চালু থাকলে historical index বর্তমান source-এর বদলে প্রতিটি page-এর frozen Markdown artifact পড়ে। Build ফাইলগুলো static/ ও production bundle—দুই জায়গাতেই লেখে, তাই clean CI build-এর deployed output-এও সেগুলো থাকে। static/ copy commit করবেন নাকি ignore করে CI-তে regenerate করবেন তা স্থির রাখুন।

Version change discovery

versions

Document version management-কে sveltepress.versions.json থেকে স্বয়ংক্রিয়ভাবে আবিষ্কার করা হয়। Discovery বন্ধ করুন বা অন্য manifest path চয়ন করুন:

import {  } from '@sveltepress/vite'

({
  : false,
})

({
  : { : 'config/document-versions.json' },
})
ts

সক্রিয় হলে virtual:sveltepress/versions manifest ও route helper-এর পাশাপাশি changeSetsresolveVersionChanges(versionId?) export করে। Snapshot ও What’s New ব্যবহারের জন্য ডকুমেন্ট সংস্করণ ব্যবস্থাপনা দেখুন।

Locales, Pagefind, and locale hooks

locales

Opt-in multi-locale map keyed by URL prefix. See আন্তর্জাতিকীকরণ .

pagefind

Post-build Pagefind indexing for Local Search. Set false to disable. Historical indexes freeze via syncHistoricalPagefind.

virtual:sveltepress/locale

Exports locales, resolveLocale, resolveLocalizedPath, resolveLocaleSwitch when locales are configured.

createLocaleHandle

From /vite/hooks — sets SSR <html lang>. See the i18n guide.

ResolvedTheme

name

থিমের নাম

globalLayout

গ্লোবাল লে আউটের অ্যাবসোলুট পাথ। svelte ফাইল হতে হবে যেমন: path.resolve(process.cwd(), 'ThemeGlobalLayout.svelte')

pageLayout

পেজ লে আউটের অ্যাবসোলুট পাথ svelte ফাইল হতে হবে যেমন: path.resolve(process.cwd(), 'ThemePageLayout.svelte')

vitePlugins

  • যদি এক বা একাধিক প্লাগিন পাস করা হয়, সেই প্লাগিনগুলো sveltepress এর সামনে অ্যাপ্লাই করা হবে।
  • যদি একটি ফাংশন পাস করা হয়, এটি sveltepress অ্যাক্সেপ্ট করবে এবং প্লাগিনের গ্রুপ রিটার্ন করবে। আপনি রিটার্নকৃত প্লাগিন চেইনে sveltepress এর প্লাগিন অর্ডার কাস্টমাইজ করতে পারেন।
থিম ভিট প্লাগিন সম্পর্কে

এটি হয়ত একটু অদ্ভুত যে থিমের ভিট প্লাগিন আছে। কিন্তু এটি উপকারী যখন থিম কিছু ভার্চুয়াল মডিউল যুক্ত করতে চায় অথবা কিছু টেম্প ফাইল তৈরি করতে চায়।

highlighter

কোড হাইলাইটিং এর জন্য ব্যবহৃত। যেমন, ডিফল্ট থিম shiki ব্যবহার করে। বিস্তারিত ব্যবহারের জন্য ডিফল্ট থিম হাইলাইটার সোর্স কোড দেখুন।

remarkPlugins

The remark plugins ব্যবহৃত হয় মার্কডাউন পার্সিং এর জন্য। বিস্তারিত জানতে Remark plugins পড়ুন।

rehypePlugins

html জেনারেটরের জন্য The rehype plugins ব্যবহৃত হয়। বিস্তারিত জানতে Rehype plugins পড়ুন।

প্লাগিনের ধারাবাহিকতা

থিম কর্তৃক প্রোভাইডকৃত The remark এবং rehype plugins তা ভিট প্লাগিনের প্রোভাইডকৃত প্লাগিনের পূর্বে কল করা হবে। উদাহরণস্বরূপ:

vite.config.(js|ts)
import {  } from '@sveltepress/theme-default'
import {  } from '@sveltepress/vite'
import {  } from 'vite'

export default ({
  : [
    ({
      : (/* theme options */),
      : [/* yourRemarkPlugin */]
    })
  ]
})
ts

yourRemarkPlugin রান হবে ডিফল্ট থিমের remark plugins এর পরে।

footnoteLabel

ফুটনোটের টাইটেল কাস্টমাইজ করতে। ডিফল্ট হচ্ছে "Footnotes"

Virtual modules

virtual:sveltepress/site

এই মডিউল siteConfig কে হোল্ড করে। এখানে একটি উদাহরণ-

The site title is: Sveltepress

The site description is: A content centered site build tool

<script>
  import  from 'virtual:sveltepress/site'
</script>

<p>The site title is: {.}</p>
<p>The site description is: {.}</p>
svelte
View code

Low level API

The @sveltepress/vite এর mdToSvelte একটি লোড লেভেল এপিআই ফাংশন আছে এটি Sveltepress এ সকল বড় বড় মার্কডাউন রেন্ডারের জন্য ব্যবহৃত হয়। এটি Svelte এর সাথে সম্পৃক্ত আরো বেসিক মার্কডাউন রেন্ডারিং ইঞ্জিনের জন্য ব্যবহার করা যাবে ।

ব্যবহারবিধি:

import {  } from '@sveltepress/vite'

const  = `
---
title: Foo
---
<script>
  const foo = 'bar'
</script>
# Title

foo in script is: {foo}

[Foo Link](https://foo.bar)
`

const { ,  } = await ({
  ,
  : [], // your custom remark plugins
  : [], // your custom rehype plugins
  : async (, , ) => .('The rendered highlighted code html'), // your custom code highlighter
  : 'foo.md', // the virtual file path
})

// The rendered svelte code


// The frontmatter object, { title: 'Foo' }
ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Literal code প্রস্তুতি

@sveltepress/vite/highlight

@sveltepress/vite/highlight থেকে prepareCodeBlock import করে তৃতীয় argument-এ { mode: 'literal' } দিন। এই mode source transform করে না: // [svp! ...] code command এবং প্রথম লাইনের // @noErrors হুবহু processedCode-এ থাকে। তবে metadata parsing চালু থাকে, তাই titleln যথাক্রমে title এবং line-number state নির্ধারণ করে।

import {  } from '@sveltepress/vite/highlight'

const  = (
  '// @noErrors\nconst value = 1 ',
  'title="source.md" ln',
  { : 'literal' },
)
ts

এখানে prepared.processedCode input-এর সমান, prepared.title হলো 'source.md', এবং prepared.containLineNumbers হলো trueprepared.noErrors থাকে false, কারণ literal mode-এ @noErrors সংরক্ষিত হলেও directive হিসেবে process হয় না।

Typescript এর ব্যবহার

প্লাগিন অপশন এবং ভার্চুয়াল মডিউল টাইপ টিপসের জন্য src/app.d.ts তে @sveltepress/vite/types যুক্ত করতে হবে

/src/app.d.ts
/// <reference types="@sveltepress/vite/types" />

// এখানে আপনার অন্যান্য টাইপ থাকবে
ts
সর্বশেষ আপডেট: 2026/09/05 03:57