From 60d6a34d14bb1d210dad9c96768f797460e3a120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 4 Mar 2020 23:27:39 +0100 Subject: [PATCH] add basic support for multiple imports --- content/posts/test.md | 4 ++++ src/components/Preview.vue | 16 ++++++++++++++-- src/demos/Time/index.vue | 14 ++++++++++++++ src/demos/Time/style.css | 0 src/templates/Post.vue | 10 +++++----- 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/demos/Time/index.vue create mode 100644 src/demos/Time/style.css diff --git a/content/posts/test.md b/content/posts/test.md index ae16219e..addd4477 100644 --- a/content/posts/test.md +++ b/content/posts/test.md @@ -5,3 +5,7 @@ slug: test test +import Preview from '../../src/components/Preview.vue' + + + \ No newline at end of file diff --git a/src/components/Preview.vue b/src/components/Preview.vue index f20a1ff4..4541cfb0 100644 --- a/src/components/Preview.vue +++ b/src/components/Preview.vue @@ -28,8 +28,20 @@ export default { }, mounted() { - this.content = require(`!!raw-loader!~/components/${this.path}`).default - this.component = require(`~/components/${this.path}`).default + const files = require.context(`~/demos/`, true) + .keys() + .filter(path => path.startsWith(`./${this.path}`)) + .filter(path => path.endsWith('.vue') || path.endsWith('.js') || path.endsWith('.css')) + .map(path => path.replace('./', '')) + .map(path => ({ + path: path.replace(`${this.path}/`, ''), + content: require(`!!raw-loader!~/demos/${path}`).default + })) + + console.log(files) + + // this.content = require(`!!raw-loader!~/components/${this.path}`).default + // this.component = require(`~/components/${this.path}`).default } } diff --git a/src/demos/Time/index.vue b/src/demos/Time/index.vue new file mode 100644 index 00000000..191b3898 --- /dev/null +++ b/src/demos/Time/index.vue @@ -0,0 +1,14 @@ + + +s \ No newline at end of file diff --git a/src/demos/Time/style.css b/src/demos/Time/style.css new file mode 100644 index 00000000..e69de29b diff --git a/src/templates/Post.vue b/src/templates/Post.vue index 349938a9..3097cbe7 100644 --- a/src/templates/Post.vue +++ b/src/templates/Post.vue @@ -23,16 +23,16 @@ export default { // console.log(tiptap()) - new Editor({ - element: this.$refs.editor, - content: '

test strong

', - }) + // new Editor({ + // element: this.$refs.editor, + // content: '

test strong

', + // }) // .setContent('

hey

') // .registerCommand('lol', (next) => { // console.log('lol') // next() // }) - .focus('end') + // .focus('end') // .insertText('mega ') // .focus('start') // .command('insertText', 'giga ')