From 14bcf806594617dcf75bbe0e6437de7a848f85f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 2 Feb 2021 23:28:17 +0100 Subject: [PATCH] fix react renderer --- docs/gridsome.server.js | 4 +-- docs/src/templates/DemoPage/index.vue | 36 ++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/gridsome.server.js b/docs/gridsome.server.js index b098dd2ba..f86728d01 100644 --- a/docs/gridsome.server.js +++ b/docs/gridsome.server.js @@ -100,9 +100,9 @@ module.exports = function (api) { /** * Generate pages for all demo components for testing purposes */ - globby.sync('./src/demos/**/index.vue').forEach(file => { + globby.sync('./src/demos/**/index.(vue|jsx)').forEach(file => { const match = file.match( - new RegExp(/\.\/src\/demos\/([\S]+)\/index.vue/i), + new RegExp(/\.\/src\/demos\/([\S]+)\/index.(vue|jsx)/i), ) if (!match) { diff --git a/docs/src/templates/DemoPage/index.vue b/docs/src/templates/DemoPage/index.vue index 3846b55e9..473f58c33 100644 --- a/docs/src/templates/DemoPage/index.vue +++ b/docs/src/templates/DemoPage/index.vue @@ -1,6 +1,6 @@ @@ -30,6 +30,40 @@ export default { } }, + methods: { + fromString(value) { + if (typeof value !== 'string') { + return value + } + + if (value.match(/^\d*(\.\d+)?$/)) { + return Number(value) + } + + if (value === 'true') { + return true + } + + if (value === 'false') { + return false + } + + if (value === 'null') { + return null + } + + return value + }, + }, + + computed: { + props() { + return Object.fromEntries(Object + .entries(this.$route.query) + .map(([key, value]) => [key, this.fromString(value)])) + }, + }, + mounted() { this.resizeObserver = new window.ResizeObserver(items => { if (window.parentIFrame) {