diff --git a/packages/plugin-docusaurus/CHANGELOG.md b/packages/plugin-docusaurus/CHANGELOG.md index 4424ae1c..fdb9d7f9 100644 --- a/packages/plugin-docusaurus/CHANGELOG.md +++ b/packages/plugin-docusaurus/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.4.18 + +feat: add url params for mobilePreview + ## 1.4.17 ### Patch Changes diff --git a/packages/plugin-docusaurus/package.json b/packages/plugin-docusaurus/package.json index 59420a12..ccd98653 100644 --- a/packages/plugin-docusaurus/package.json +++ b/packages/plugin-docusaurus/package.json @@ -1,6 +1,6 @@ { "name": "@ice/pkg-plugin-docusaurus", - "version": "1.4.17", + "version": "1.4.18", "description": "@ice/pkg plugin for component and docs preview.", "main": "es2017/index.mjs", "exports": { diff --git a/packages/plugin-docusaurus/src/remark/extractCode.js b/packages/plugin-docusaurus/src/remark/extractCode.js index 07dc34c6..329d1506 100644 --- a/packages/plugin-docusaurus/src/remark/extractCode.js +++ b/packages/plugin-docusaurus/src/remark/extractCode.js @@ -15,10 +15,10 @@ const escapeCode = (code) => { /** * Remark Plugin to extract codeBlock & rendered as component * @type {import('unified').Plugin} - * @param {options: { mobilePreview: boolean; baseUrl: string; }} + * @param {options: { mobilePreview: boolean; baseUrl: string; mobilePreviewUrlParams: string; }} */ const extractCodePlugin = (options) => { - const { mobilePreview = false, baseUrl = '/' } = options; + const { mobilePreview = false, baseUrl = '/', mobilePreviewUrlParams = '' } = options; const transformer = (ast, vfile) => { const demosMeta = []; @@ -53,7 +53,7 @@ const extractCodePlugin = (options) => { idx: index, demoFilename, demoFilepath, - url: path.join(baseUrl.startsWith('/') ? '' : '/', baseUrl, 'demos', demoFilename, '/'), + url: `${path.join(baseUrl.startsWith('/') ? '' : '/', baseUrl, 'demos', demoFilename, '/')}?${mobilePreviewUrlParams}`, }); demoIndex += 1; } diff --git a/packages/plugin-docusaurus/src/template/docusaurus.hbs b/packages/plugin-docusaurus/src/template/docusaurus.hbs index 83ab37e8..9843ad0c 100644 --- a/packages/plugin-docusaurus/src/template/docusaurus.hbs +++ b/packages/plugin-docusaurus/src/template/docusaurus.hbs @@ -46,7 +46,7 @@ const config = { sidebarItemsGenerator: {{{sidebarItemsGenerator}}}, {{/if}} remarkPlugins: [ - [extractCode, { mobilePreview: {{mobilePreview}}, baseUrl: '{{baseUrl}}' }], + [extractCode, { mobilePreview: {{mobilePreview}}, baseUrl: '{{baseUrl}}', mobilePreviewUrlParams: '{{mobilePreviewUrlParams}}' }], {{#if remarkPlugins}} {{#each remarkPlugins}} {{{this}}}, diff --git a/packages/plugin-docusaurus/src/types.mts b/packages/plugin-docusaurus/src/types.mts index ba278c42..dcd96bc8 100644 --- a/packages/plugin-docusaurus/src/types.mts +++ b/packages/plugin-docusaurus/src/types.mts @@ -66,6 +66,10 @@ export interface PluginDocusaurusOptions { * Whether preview components of mobile styles */ mobilePreview?: boolean; + /** + * When mobilePreview is true, the url parameters of the mobile preview page + */ + mobilePreviewUrlParams?: string; /** * Default locale that does not have its name in the base URL