From 032cacbbb3053305ea23d20d82e1d0d7978b2497 Mon Sep 17 00:00:00 2001 From: Caxer Tsang Date: Mon, 13 Jul 2020 18:13:34 +0800 Subject: [PATCH 1/2] feat: keep custom block type when block has lang --- src/index.ts | 6 +++--- src/utils.ts | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 86c612e..bebf604 100644 --- a/src/index.ts +++ b/src/index.ts @@ -483,10 +483,10 @@ export default function vue(opts: Partial = {}): Plugin { `export * from '${createVuePartRequest( filename, (typeof block.attrs.lang === 'string' && block.attrs.lang) || - createVuePartRequest.defaultLang[block.type] || - block.type, + createVuePartRequest.defaultLang[block.type], 'customBlocks', - index + index, + block.type )}'` }) diff --git a/src/utils.ts b/src/utils.ts index 82bd16d..a17af10 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -22,7 +22,13 @@ export interface VuePartRequestMeta { } export interface VuePartRequestCreator { - (filename: string, lang: string, type: string, index?: number): string + ( + filename: string, + lang: string, + type: string, + index?: number, + blockType?: string + ): string defaultLang: { [key: string]: string @@ -68,7 +74,8 @@ export const createVuePartRequest: VuePartRequestCreator = (( filename: string, lang: string | undefined, type: string, - index?: number + index?: number, + blockType?: string ): string => { lang = lang || createVuePartRequest.defaultLang[type] @@ -76,7 +83,7 @@ export const createVuePartRequest: VuePartRequestCreator = (( const query = match ? queryString.parse(match[2]) : {} - query[PARAM_NAME] = [type, index, lang] + query[PARAM_NAME] = [type, index, blockType, lang] .filter(it => it !== undefined) .join('.') From 7ca6050ef68b70c72ab31a84ed5a917e88273995 Mon Sep 17 00:00:00 2001 From: Caxer Tsang Date: Tue, 14 Jul 2020 16:06:49 +0800 Subject: [PATCH 2/2] fix: add back import statement to custom block --- src/index.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index bebf604..3fd8850 100644 --- a/src/index.ts +++ b/src/index.ts @@ -478,16 +478,19 @@ export default function vue(opts: Partial = {}): Plugin { descriptor.customBlocks.forEach((block, index) => { if (!isAllowed(block.type)) return + const vuePartRequest = createVuePartRequest( + filename, + (typeof block.attrs.lang === 'string' && block.attrs.lang) || + createVuePartRequest.defaultLang[block.type], + 'customBlocks', + index, + block.type + ) result.code += '\n' + - `export * from '${createVuePartRequest( - filename, - (typeof block.attrs.lang === 'string' && block.attrs.lang) || - createVuePartRequest.defaultLang[block.type], - 'customBlocks', - index, - block.type - )}'` + `export * from '${vuePartRequest}'\n` + + `import __custom_block_${index}__ from '${vuePartRequest}'\n` + + `__custom_block_${index}__(__vue_component__)` }) dT( pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy