From b2d775bb764fe9196c16fa8656d0c3cbe76c8297 Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Thu, 23 Jun 2022 18:09:19 +0200 Subject: [PATCH] feat: variable binding (#1266) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Chopin --- docs/components/content/Playground.vue | 7 +- playground/pages/playground.vue | 28 +++++++- src/runtime/components/MarkdownRenderer.ts | 60 +++++++++++----- .../remark-mdc/from-markdown.ts | 18 ++++- .../remark-mdc/micromark-extension/index.ts | 3 +- .../micromark-extension/tokenize-binding.ts | 71 +++++++++++++++++++ test/basic.test.ts | 2 + test/features/renderer-markdown.ts | 56 +++++++++++++++ test/fixtures/basic/pages/parse.vue | 19 +++++ 9 files changed, 243 insertions(+), 21 deletions(-) create mode 100644 src/runtime/markdown-parser/remark-mdc/micromark-extension/tokenize-binding.ts create mode 100644 test/features/renderer-markdown.ts create mode 100644 test/fixtures/basic/pages/parse.vue diff --git a/docs/components/content/Playground.vue b/docs/components/content/Playground.vue index 90ab3e46d..c62c9d932 100644 --- a/docs/components/content/Playground.vue +++ b/docs/components/content/Playground.vue @@ -3,7 +3,11 @@ import { ref, useAsyncData, shallowRef, computed, onMounted, watch } from '#impo import { parse } from '../../../src/runtime/markdown-parser' import { useShiki } from '../../editor/useShiki.ts' -const INITIAL_CODE = `# MDC +const INITIAL_CODE = `--- +title: MDC +--- + +# {{ $doc.title}} MDC stands for _**M**ark**D**own **C**omponents_. @@ -49,6 +53,7 @@ const { data: doc, refresh } = await useAsyncData('playground', async () => { _draft: false, _type: 'markdown', updatedAt: new Date().toISOString(), + ...parsed.meta || {}, ...parsed } } catch (e) { diff --git a/playground/pages/playground.vue b/playground/pages/playground.vue index 7071bca27..1e4f58e97 100644 --- a/playground/pages/playground.vue +++ b/playground/pages/playground.vue @@ -1,7 +1,14 @@