vitepress-plugin-sfc 2.0.0-beta.2 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,25 +1,26 @@
1
1
  # VitePress Plugin SFC
2
2
 
3
- [Documentation](https://vitepress-plugin-sfc-playgrou.vercel.app/)
3
+ [Documentation](https://vitepress-plugin-sfc-playgrou.vercel.app/) | [中文](README-zh-CN.md)
4
4
 
5
5
  Allows you to write Vue SFC within Markdown files and render them in VitePress.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```shell
10
- npm install -D vitepress-plugin-sfc
10
+ npm install -D vitepress-plugin-sfc@latest
11
11
  ```
12
12
 
13
13
  ## Configuration
14
14
 
15
- Configure it in `.vitepress/config.ts`:
15
+ Configure it in `.vitepress/config.ts` and `.vitepress/theme/index.ts`:
16
+
17
+ `.vitepress/config.ts`
16
18
 
17
19
  ```ts
18
20
  import { defineConfig } from "vitepress";
19
21
  import { sfcPlugin, sfcRegistryVitePlugin } from "vitepress-plugin-sfc";
20
22
 
21
23
  export default defineConfig({
22
- // ...other configurations
23
24
  markdown: {
24
25
  config: (md) => {
25
26
  md.use(sfcPlugin);
@@ -31,6 +32,21 @@ export default defineConfig({
31
32
  });
32
33
  ```
33
34
 
35
+ `.vitepress/theme/index.ts`
36
+
37
+ ```ts
38
+ import DefaultTheme from "vitepress/theme";
39
+ import { enhanceAppWithComponentView } from "vitepress-plugin-sfc/client";
40
+ import "vitepress-plugin-sfc/style";
41
+
42
+ export default {
43
+ extends: DefaultTheme,
44
+ async enhanceApp({ app }) {
45
+ await enhanceAppWithComponentView(app);
46
+ },
47
+ };
48
+ ```
49
+
34
50
  ## Usage
35
51
 
36
52
  Wrap **valid** Vue SFC content with `:::sfc`:
@@ -0,0 +1 @@
1
+ import{t as e}from"./export-helper-9pbmIWWh.mjs";import{useData as t}from"vitepress";import{Fragment as n,computed as r,createElementBlock as i,createElementVNode as a,defineComponent as o,normalizeClass as s,openBlock as c,ref as l,renderList as u,renderSlot as d,toDisplayString as f,useId as p,vShow as m,withDirectives as h}from"vue";var g=o({__name:`GroupTabs`,props:{locale:{type:Object,required:!1}},setup(e,{expose:n}){n();let i={en:{label:{preview:`Preview`,code:`Source Code`}},zh:{label:{preview:`预览`,code:`源代码`}}},a=e,{lang:o}=t(),s={DEFAULT_LOCALE:i,props:a,lang:o,currentLocale:r(()=>a.locale?.[o.value]||i[o.value]),activedTab:l(`preview`),tabGroupId:p()};return Object.defineProperty(s,`__isScriptSetup`,{enumerable:!1,value:!0}),s}});const _={class:`vp-component-tabs`},v=[`id`,`name`,`data-checked`],y=[`for`,`onClick`];function b(e,t,r,o,l,p){return c(),i(`div`,_,[a(`header`,null,[(c(!0),i(n,null,u(o.currentLocale.label,(e,t)=>(c(),i(n,{key:t},[a(`input`,{id:`tab-${o.tabGroupId}-${t}`,type:`radio`,name:`vp-component-tabs-${o.tabGroupId}`,style:{position:`fixed`,opacity:`0`,"pointer-events":`none`},"data-checked":o.activedTab===t},null,8,v),a(`label`,{for:`tab-${o.tabGroupId}-${t}`,onClick:e=>o.activedTab=t},f(e),9,y)],64))),128))]),h(a(`main`,null,[d(e.$slots,`default`)],512),[[m,o.activedTab===`preview`]]),h(a(`div`,{class:s(`language-vue${o.activedTab===`code`?` active`:``}`),style:{margin:`0px`}},[t[0]||=a(`button`,{title:`copy source code`,class:`copy`},null,-1),t[1]||=a(`span`,{class:`lang`},`Vue`,-1),d(e.$slots,`highlight`)],2),[[m,o.activedTab===`code`]])])}var x=e(g,[[`render`,b],[`__file`,`/home/runner/work/vitepress-plugin-sfc/vitepress-plugin-sfc/src/client/GroupTabs.vue`]]);export{x as default};
@@ -0,0 +1,2 @@
1
+ import { a as enhanceAppWithComponentView, i as configSymbol, n as Config, r as GroupTabsProps, t as ComponentViewProps } from "./index-DHKDP_Um.mjs";
2
+ export { ComponentViewProps, Config, GroupTabsProps, configSymbol, enhanceAppWithComponentView };
@@ -0,0 +1 @@
1
+ import{t as e}from"./export-helper-9pbmIWWh.mjs";import{computed as t,createBlock as n,createElementBlock as r,defineComponent as i,getCurrentInstance as a,inject as o,openBlock as s,renderSlot as c,resolveDynamicComponent as l,withCtx as u}from"vue";var d=i({__name:`ComponentView`,props:{render:{type:[String,Object],required:!1},disableRender:{type:Boolean,required:!1,default:!1}},setup(e,{expose:n}){n();let r=e,i=o(m),s=a(),c={props:r,injectedConfig:i,instance:s,config:t(()=>{let{render:e,disableRender:t}=i,n={render:e||r.render,disableRender:t??r.disableRender},a=s.appContext.app.component(n.render);return a||console.warn(`[vitepress-plugin-sfc] Unregistered component: ${n.render}`),{...n,render:a}})};return Object.defineProperty(c,`__isScriptSetup`,{enumerable:!1,value:!0}),c}});function f(e,t,i,a,o,d){return s(),r(`div`,null,[!a.config.render||a.config.disableRender?c(e.$slots,`default`,{key:0}):(s(),n(l(a.config.render),{key:1},{highlight:u(()=>[c(e.$slots,`highlight`)]),default:u(()=>[c(e.$slots,`default`)]),_:3}))])}var p=e(d,[[`render`,f],[`__file`,`/home/runner/work/vitepress-plugin-sfc/vitepress-plugin-sfc/src/client/ComponentView.vue`]]);const m=Symbol(`__vitepress_plugin_sfc_config`),h={render:`GroupTabs`};async function g(e,t){e.component(`ComponentView`,p);let n={...h,...t};if(e)e.provide(m,n);else throw Error("[vitepress-plugin-sfc] The `useConfig` must be called within a Vue component if not providing an app");let{render:r,disableRender:i}=n;if(!i&&r===`GroupTabs`){let t=await import(`./GroupTabs-voGdJiur.mjs`);e.component(`GroupTabs`,t.default)}}export{m as configSymbol,g as enhanceAppWithComponentView};
@@ -0,0 +1 @@
1
+ var e=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n};export{e as t};
@@ -0,0 +1,22 @@
1
+ import { EnhanceAppContext } from "vitepress";
2
+
3
+ //#region src/client/index.d.ts
4
+ interface ComponentViewProps {
5
+ render?: "GroupTabs" | "SourceCodeButton" | (string & {});
6
+ disableRender?: boolean;
7
+ }
8
+ interface GroupTabsProps {
9
+ locale?: Record<string, {
10
+ label: {
11
+ preview: string;
12
+ code: string;
13
+ };
14
+ }>;
15
+ }
16
+ type Config = ComponentViewProps & {
17
+ groupTabs?: GroupTabsProps;
18
+ };
19
+ declare const configSymbol: unique symbol;
20
+ declare function enhanceAppWithComponentView(app: EnhanceAppContext["app"], config?: Config): Promise<void>;
21
+ //#endregion
22
+ export { enhanceAppWithComponentView as a, configSymbol as i, Config as n, GroupTabsProps as r, ComponentViewProps as t };