BuptStEve / vuepress-plugin-demo-code

📝 Demo and code plugin for vuepress
https://buptsteve.github.io/vuepress-plugin-demo-code/
MIT License
125 stars 28 forks source link

feat: Vuepress 2 support #41

Open tomatopickle opened 2 years ago

tomatopickle commented 2 years ago

Is your feature request related to a problem? Please describe. I really like this plugin, but I've switched to Vuepress 2. Can you please make this plugin Vuepress 2 compatible?

Thanks

BuptStEve commented 2 years ago

OK, I'll try it...

$ npm i -D vuepress-plugin-demo-code@next
# OR
$ pnpm i -D vuepress-plugin-demo-code@next
# OR
$ yarn add -D vuepress-plugin-demo-code@next
tomatopickle commented 2 years ago

Does this support Vuepress 2 now?

BuptStEve commented 2 years ago

Does this support Vuepress 2 now?

Yeah, try this one~

$ npm i -D vuepress-plugin-demo-code@next
# OR
$ yarn add -D vuepress-plugin-demo-code@next
jtommy commented 2 years ago

@BuptStEve it doesn't work properly, is it a stable version?

BuptStEve commented 2 years ago

@BuptStEve it doesn't work properly, is it a stable version?

what's wrong with it? Please provide some pictures or a demo? It's not a stable version, because vuepress@2 is in beta version.

jtommy commented 2 years ago

@BuptStEve The path separator doesn't look good for windows OS

 Plugin: vite:import-analysis
  File: C:/Users/Walter/Github/oruga/packages/docs-next/.vuepress/.temp/internal/clientAppEnhances.js
  3  |  import clientAppEnhance2 from 'C:/Users/Walter/Github/oruga/packages/docs-next/node_modules/@vuepress/plugin-theme-data/lib/client/clientAppEnhance.js'
  4  |  import clientAppEnhance3 from 'C:/Users/Walter/Github/oruga/packages/docs-next/node_modules/@vuepress/theme-default/lib/client/clientAppEnhance.js'
  5  |  import clientAppEnhance4 from 'C:\Users\Walter\Github\oruga\packages\docs-next\node_modules\vuepress-plugin-demo-code\src\enhanceAppFile.js'     
     |                                 ^
  6  |  import clientAppEnhance5 from 'C:/Users/Walter/Github/oruga/packages/docs-next/.vuepress/clientAppEnhance.ts'

and fiixing it manually

image

BuptStEve commented 2 years ago

@jtommy Well, I get it. I'll fix this ASAP. Because there are too many breaking changes in Vuepress's beta version, such as this:

image
jtommy commented 2 years ago

Thanks. What Vuepress 2 version are you supporting at the moment?

BuptStEve commented 2 years ago

@jtommy 2.0.0-beta.27

I just make it compatible with 2.0.0-beta.37, please wait a moment.

Please try this one~ vuepress-plugin-demo-code@1.0.0-2

jtommy commented 2 years ago

@BuptStEve 2.0.0-beta.38

Uncaught SyntaxError: The requested module '/@fs/C:/Users/Walter/Github/oruga/packages/docs-next/node_modules/codesandbox-import-utils/lib/api/define.js' does not provide an export named 'getParameters'

SyntaxError: The requested module '/@fs/C:/Users/Walter/Github/oruga/packages/docs-next/node_modules/escape-html/index.js' does not provide an export named 'default' (at highlight.js:2:8)

It looks like all import from external libs are broken, probably due to Vite

BuptStEve commented 2 years ago

@jtommy Maybe add this for now~

// config.js
{
  // ...
  bundlerConfig: {
    viteOptions: {
        optimizeDeps: {
            include: [
                'prismjs',
                'escape-html',
                'codesandbox-import-utils/lib/api/define'
            ],
        }
    }
  }
}
BuptStEve commented 2 years ago

@jtommy I just publish this version: vuepress-plugin-demo-code@1.0.0-3

jtommy commented 2 years ago

@BuptStEve thanks. I found the same workaround after my last message. Your last version is ok but you are setting Vue 2, why?

Anyway, I don't think I to be able to use your plugin because in the Vuepress 2.x there is a limit of a script for each .md

BuptStEve commented 2 years ago

@jtommy I'll use Vue3 as default in next commit. It's fine that you won't use it, every package suits it's own scenario.

jtommy commented 2 years ago

Or you might add a config to allow us to customize the Vue CDN.

I think the major part of components doc needs to show more than one example for each page (.MD).

BuptStEve commented 2 years ago

@jtommy vuepress-plugin-demo-code@1.0.0-4 add vueVersion~ The feature "more than one <script>" is not that easy with current code.

jtommy commented 2 years ago

Any workaround to meet the need?

bobobabab commented 2 years ago

使用了没效果是怎么回事,v2.0.0-beta.38, vuepress-plugin-demo-code@1.0.0-4

BuptStEve commented 2 years ago

使用了没效果是怎么回事,v2.0.0-beta.38, vuepress-plugin-demo-code@1.0.0-4

27c7477c-7266-44c8-8ca0-7b104bc53de7 image

bobobabab commented 2 years ago

vuepress-plugin-demo-code@1.0.0-4 加了template 预览效果显示不出来,需要怎么处理?

BuptStEve commented 2 years ago

@bobobabab 给个复现仓库看看?

bobobabab commented 2 years ago

@BuptStEve
image image image

BuptStEve commented 2 years ago

@bobobabab template display: none; 了?

bobobabab commented 2 years ago

@BuptStEve 是的 要配置么还是直接css改

giserMao commented 2 years ago

@BuptStEve vuepress2.0.0 beta4 改变了plugins的引入方式,这边有计划做适配吗

bobobabab commented 1 year ago

vuepress2.x support copy button?