import{B as e,P as t,_ as n,f as r,g as i,h as a,l as o}from"./runtime-core.esm-bundler-CZvn3YaB.js";import{t as s}from"./plugin-vue_export-helper-CxTVcLa7.js";var c=JSON.parse(`{"path":"/guide/code/code-sandbox/","title":"Code Sandbox | 指南","lang":"zh-CN","frontmatter":{"title":"Code Sandbox","icon":"lucide:codesandbox","createTime":"2024/04/04 03:42:13","permalink":"/guide/code/code-sandbox/","description":"主题支持在 Markdown 文件中嵌入 Code Sandbox。 配置 此功能默认不启用,你可以在配置文件中启用它。 .vuepress/config.ts 语法 简单语法 将 Code Sandbox 嵌入到页面中 使用 Code Sandbox 跳转按钮 更多选项 id: Code Sandbox ID title: Code Sandbox ...","head":[["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"Code Sandbox\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2025-10-07T15:13:09.000Z\\",\\"author\\":[]}"],["meta",{"property":"og:url","content":"https://theme-plume.vuejs.press/guide/code/code-sandbox/"}],["meta",{"property":"og:site_name","content":"Plume 主题"}],["meta",{"property":"og:title","content":"Code Sandbox"}],["meta",{"property":"og:description","content":"主题支持在 Markdown 文件中嵌入 Code Sandbox。 配置 此功能默认不启用,你可以在配置文件中启用它。 .vuepress/config.ts 语法 简单语法 将 Code Sandbox 嵌入到页面中 使用 Code Sandbox 跳转按钮 更多选项 id: Code Sandbox ID title: Code Sandbox ..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["meta",{"property":"og:updated_time","content":"2025-10-07T15:13:09.000Z"}],["meta",{"property":"article:modified_time","content":"2025-10-07T15:13:09.000Z"}],["link",{"rel":"alternate","hreflang":"en-us","href":"https://theme-plume.vuejs.press/en/guide/code/code-sandbox/"}]]},"readingTime":{"minutes":0.7,"words":209},"git":{"createdTime":1712247346000,"updatedTime":1759849989000,"contributors":[{"name":"pengzhanbo","username":"pengzhanbo","email":"volodymyr@foxmail.com","commits":4,"avatar":"https://avatars.githubusercontent.com/pengzhanbo?v=4","url":"https://github.com/pengzhanbo"}],"changelog":[{"hash":"4d2361a7046214fe0f4e4af01831107fd00e38ad","time":1759849989000,"email":"volodymyr@foxmail.com","author":"pengzhanbo","message":"feat(theme)!: add collections support (#704)"},{"hash":"0fd6cac57412002f4d72dc10378789b529adc357","time":1742063370000,"email":"volodymyr@foxmail.com","author":"pengzhanbo","message":"refactor(theme): improve types and flat config (#524)"},{"hash":"b600e20ba975a55464bd75290ff02cfc66b8f52a","time":1714322245000,"email":"volodymyr@foxmail.com","author":"pengzhanbo","message":"docs: update docs"},{"hash":"4349ab023ca3762f521c33a04301aae39b6c102d","time":1712247346000,"email":"volodymyr@foxmail.com","author":"pengzhanbo","message":"docs: update doc"}]},"autoDesc":true,"filePathRelative":"guide/repl/codeSandbox.md","headers":[],"bulletin":false}`),l={name:`codeSandbox.md`},u={class:`code-block-title`,"data-title":`.vuepress/config.ts`},d={class:`code-block-title-bar`},f={class:`title`};function p(s,c,l,p,m,h){let g=e(`VPIcon`),_=e(`CodeSandboxViewer`);return t(),r(`div`,null,[c[2]||=o(`p`,null,[i(`主题支持在 Markdown 文件中嵌入 `),o(`a`,{href:`https://codesandbox.io`,target:`_blank`,rel:`noopener noreferrer`},`Code Sandbox`),i(`。`)],-1),c[3]||=o(`h2`,{id:`配置`,tabindex:`-1`},[o(`a`,{class:`header-anchor`,href:`#配置`},[o(`span`,null,`配置`)])],-1),c[4]||=o(`p`,null,`此功能默认不启用,你可以在配置文件中启用它。`,-1),o(`div`,u,[o(`div`,d,[o(`span`,f,[n(g,{provider:`iconify`,name:`vscode-icons:file-type-typescript`}),c[0]||=i(`.vuepress/config.ts`,-1)])]),c[1]||=a(`
export default defineUserConfig({
theme: plumeTheme({
markdown: {
codesandbox: true,
},
})
})将 Code Sandbox 嵌入到页面中
@[codesandbox](id)使用 Code Sandbox 跳转按钮
@[codesandbox button](workspace/id)@[codesanbox title="xxx" layout="Editor+Preview" height="500px" navbar="false" console](id#filepath)id: Code Sandbox IDtitle: Code Sandbox 标题layout: 代码预览布局 可选值: Preview, Editor, Editor+Previewheight: 代码预览高度navbar: 是否显示导航栏,默认为 trueconsole: 是否显示控制台,默认为 falsefilepath: 文件路径codeSandbox 跳转按钮:
@[codesandbox button](reaction/5wyzu)输出:
`,13),n(_,{width:`100%`,height:`500px`,user:`reaction`,id:`5wyzu`,title:``,navbar:``,layout:``,type:`button`,filepath:``}),c[6]||=a(`codeSandbox 内嵌到页面中:
@[codesandbox](5wyzu)输出:
`,3),n(_,{width:`100%`,height:`500px`,user:``,id:`5wyzu`,title:``,navbar:``,layout:``,type:`embed`,filepath:``})])}var m=s(l,[[`render`,p]]);export{c as _pageData,m as default};