Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 032cacb

Browse files
committed
feat: keep custom block type when block has lang
1 parent 8733e0a commit 032cacb

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ export default function vue(opts: Partial<VuePluginOptions> = {}): Plugin {
483483
`export * from '${createVuePartRequest(
484484
filename,
485485
(typeof block.attrs.lang === 'string' && block.attrs.lang) ||
486-
createVuePartRequest.defaultLang[block.type] ||
487-
block.type,
486+
createVuePartRequest.defaultLang[block.type],
488487
'customBlocks',
489-
index
488+
index,
489+
block.type
490490
)}'`
491491
})
492492

src/utils.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ export interface VuePartRequestMeta {
2222
}
2323

2424
export interface VuePartRequestCreator {
25-
(filename: string, lang: string, type: string, index?: number): string
25+
(
26+
filename: string,
27+
lang: string,
28+
type: string,
29+
index?: number,
30+
blockType?: string
31+
): string
2632

2733
defaultLang: {
2834
[key: string]: string
@@ -68,15 +74,16 @@ export const createVuePartRequest: VuePartRequestCreator = ((
6874
filename: string,
6975
lang: string | undefined,
7076
type: string,
71-
index?: number
77+
index?: number,
78+
blockType?: string
7279
): string => {
7380
lang = lang || createVuePartRequest.defaultLang[type]
7481

7582
const match = GET_QUERY.exec(filename)
7683

7784
const query = match ? queryString.parse(match[2]) : {}
7885

79-
query[PARAM_NAME] = [type, index, lang]
86+
query[PARAM_NAME] = [type, index, blockType, lang]
8087
.filter(it => it !== undefined)
8188
.join('.')
8289

0 commit comments

Comments
 (0)