\r\n\u003C/div>\r\n`\r\n\r\n// when creating a demo section, `@/` will be replaced with `srcDir`\r\nexport const demoPlugin = (md: MarkdownIt, srcDir: string) => {\r\n const parser: RuleBlock = (state, startLine, _endLine, _silent) => {\r\n /*... some code to extract the file name from the markdown ... */\r\n token.attrSet('src', resolve(filename))\r\n return true\r\n }\r\n\r\n const renderer: RenderRule = (...args) => {\r\n /* ... some code to get `src` and check that the file exists ... */\r\n \r\n const file = readFileSync(src, 'utf8')\r\n\r\n // script\r\n token.info = `ts`\r\n token.content = findSection(file, SCRIPT_START, SCRIPT_END)\r\n const script = md.renderer.rules.fence!(...args)\r\n\r\n // template\r\n token.info = `vue-html`\r\n token.content = findSection(file, TEMPLATE_START, TEMPLATE_END)\r\n const template = md.renderer.rules.fence!(...args)\r\n\r\n // component\r\n const demo = md.render(COMPONENT_SNIPPET(src))\r\n\r\n return script + template + demo\r\n }\r\n\r\n md.renderer.rules.demo = renderer\r\n md.block.ruler.before(md.block.ruler.getRules('')[0].name, 'demo', parser)\r\n}\r\n\r\n// returns everything between the first match of `start` and the subsequent first match for `end`\r\nfunction findSection(content: string, start: RegExp, end: RegExp): string {\r\n //...\r\n}\r\n``` \r\n\r\nSo the markdown rendered used to take the line `const demo = md.render(COMPONENT_SNIPPET(src))` and automagically put the `import` statement where it needs to be and happily render the component. However, since updating to `1.0.0-alpha.11` this no longer works. In fact if I manually write out the import statement in the markdown file, everything works - so something is wrong with the way my plugin is handling the import.\r\n\r\nI looked into the way [plugin-sfc](https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-sfc) works and it looks like there was a change from `0.10.0` to `0.11.0` in the way script SFC blocks are handled.\r\n\r\nI tried to copy the way the changed code works in my plugin, but I have not managed to get it working:\r\n\r\n```ts\r\n const block = `\u003Cscript setup lang=\"ts\"> import DemoComponent from \"${src}\"; \u003C/script>`\r\n sfcBlocks.scriptSetup = block\r\n sfcBlocks.scripts.push(block)\r\n\r\n token.content = `\u003Cdiv class=\"vp-raw\"> \u003Cdemo-component/> \u003C/div>`\r\n const demo = md.renderer.rules.html_block!(...args)\r\n```\r\n\r\nDoes anyone know how this can be done? How can my plugin tell VitePress that it needs to import the demo component for this page?\r\n",[],1349,"closed","Import custom component in MarkdownIt plugin","2023-01-21T14:22:46Z","https://github.com/vuejs/vitepress/issues/1349",0.76151913,{"description":2955,"labels":2956,"number":2958,"owner":2869,"repository":2870,"state":2949,"title":2959,"updated_at":2960,"url":2961,"score":2962},"### Describe the bug\n\nExecute command npm run docs:build and throw an exception: build error:\r\nTypeError: Intl.Segmenter is not a constructor\r\n\n\n### Reproduction\n\n.vitepress config.ts\r\n```\r\nimport { defineConfig } from 'vitepress'\r\n\r\nexport default defineConfig({\r\n lang: 'en-US',\r\n lastUpdated: true,\r\n cleanUrls: true,\r\n\r\n themeConfig: {\r\n\r\n nav: nav(),\r\n\r\n sidebar: {\r\n '/rest-api/': sidebarRestApi(),\r\n }\r\n }\r\n})\r\n```\r\n\r\npackage.json\r\n```\r\n\"scripts\": {\r\n \"dev:docs\": \"npx vitepress dev docs\",\r\n \"build:docs\": \"npx vitepress build docs\",\r\n \"serve:docs\": \"npx vitepress serve docs\"\r\n },\r\n \"dependencies\": {\r\n \"vue\": \"^3.3.4\"\r\n },\r\n \"devDependencies\": {\r\n \"vitepress\": \"^1.0.0-rc.4\"\r\n }\r\n```\n\n### Expected behavior\n\nnpm run build:docs\n\n### System Info\n\n```sh\nnpx vitepress build docs\r\n\r\nvitepress v1.0.0-rc.4\r\n\r\nbuild error:\r\nTypeError: Intl.Segmenter is not a constructor\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.dev).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[2957],{"name":2916,"color":2917},2817,"Vitepress build error","2023-08-27T00:06:17Z","https://github.com/vuejs/vitepress/issues/2817",0.767842,{"description":2964,"labels":2965,"number":2966,"owner":2869,"repository":2870,"state":2949,"title":2967,"updated_at":2968,"url":2969,"score":2970},"### Is your feature request related to a problem? Please describe.\n\nCurrently the default theme hardcodes a string comparison to determine if current page is home layout:\n\n```js\nclass = {\n 'is-home': frontmatter.layout === 'home'\n}\n```\n\nThere are many occurrences in the default theme where the above expression is used to control special treatments for home pages (e.g. hide sidebar, disable local nav, expand content width in CSS).\n\nIn my case, I need to create a custom Home layout in addition to the one provided by the default theme. However, it's almost impossible to make a custom layout page behave like the home layout because of these hardcoded conditions.\n\n### Describe the solution you'd like\n\nAccept an optional config `isHomeLayout` in front-matter. When left undefined, this entry should default to `frontmatter.layout === 'home'`.\n\nExample:\n\n```md\n---\nlayout: my-custom-layout\nisHomeLayout: true\n---\n\n# My home content\n\nLorem ipsum dolor sit amet ....\n```\n\n\n### Describe alternatives you've considered\n\n_No response_\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [x] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [x] Read the [docs](https://vitepress.dev).\n- [x] Read the [Contributing Guidelines](https://github.com/vuejs/vitepress/blob/main/.github/contributing.md).\n- [x] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.",[],4671,"[default-theme] Allow custom layout used as home layout","2025-04-05T13:59:33Z","https://github.com/vuejs/vitepress/issues/4671",0.78466696,["Reactive",2972],{},["Set"],["ShallowReactive",2975],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fdCjK_3rBdb1J1oRoOQUnp5IWrK5MLNHgLePrVfMxEX8":-1},"/vuejs/vitepress/4179"]