Giter VIP home page Giter VIP logo

Comments (4)

jefrydco avatar jefrydco commented on May 29, 2024 1

Sorry for late reply, and thanks for the patch. It really worked! I also have created PR for example mentioned in #83.

from frontmatter-markdown-loader.

hmsk avatar hmsk commented on May 29, 2024

Right. #83 may answers your question.

from frontmatter-markdown-loader.

jefrydco avatar jefrydco commented on May 29, 2024

Sure, that answers my question, but the content of markdown won't render from the server. Please check out this https://github.com/jefrydco/jefrydco/tree/feat/frontmatter-markdown-loader

from frontmatter-markdown-loader.

hmsk avatar hmsk commented on May 29, 2024

Looks abusing asynchronous import which couldn't be resolved on the server-side 👀
<component :is=""> expects function which returns Promise by import for SSR + asynchronous importing. Or just a ready-made component object synchronously. Your approach is passing an object which will be fulfilled by another asynchronous process, but <component> can't wait on the server-side.

Here's the quick patch to fix the problem with synchronous way:

diff --git a/pages/blog/_slug/index.vue b/pages/blog/_slug/index.vue
index 25f5bd4..7393e4a 100644
--- a/pages/blog/_slug/index.vue
+++ b/pages/blog/_slug/index.vue
@@ -295,7 +295,7 @@ export default {
       blog: null
     }
   },
-  async created() {
+  created() {
     const slug = this.$route && this.$route.params && this.$route.params.slug
     const locale = this.$i18n.locale
     const locales = this.$i18n.locales
@@ -306,34 +306,33 @@ export default {
     try {
       if (locale === defaultLocale) {
         editPath = `contents/blogs/${slug}/index.md`
-        blog = await import(`~/contents/blogs/${slug}/index.md`)
+        blog = require(`~/contents/blogs/${slug}/index.md`)
       } else {
         editPath = `contents/blogs/${slug}/index.${locale}.md`
-        blog = await import(`~/contents/blogs/${slug}/index.${locale}.md`)
+        blog = require(`~/contents/blogs/${slug}/index.${locale}.md`)
       }

-      await (() => {
-        if (blog !== null && typeof blog !== 'undefined') {
-          const fullPath = `https://jefrydco.id/blog/${blog.attributes.slug}`
-          this.availableLocales = availableLocales
-          this.blog = {
-            img: blog.attributes.img,
-            imgCreator: blog.attributes.imgCreator,
-            title: blog.attributes.title,
-            description: blog.attributes.description,
-            postedDate: blog.attributes.postedDate,
-            updatedDate: blog.attributes.updatedDate,
-            slug: blog.attributes.slug,
-            readingTime: readingTime(blog.html),
-            component: blog.vue.component,
-            fullPath,
-            discussLink: `https://twitter.com/search?q=${encodeURIComponent(
-              fullPath
-            )}`,
-            editLink: `https://github.com/jefrydco/jefrydco/edit/master/${editPath}`
-          }
+      if (blog !== null && typeof blog !== 'undefined') {
+        const fullPath = `https://jefrydco.id/blog/${blog.attributes.slug}`
+        this.availableLocales = availableLocales
+        this.blog = {
+          img: blog.attributes.img,
+          imgCreator: blog.attributes.imgCreator,
+          title: blog.attributes.title,
+          description: blog.attributes.description,
+          postedDate: blog.attributes.postedDate,
+          updatedDate: blog.attributes.updatedDate,
+          slug: blog.attributes.slug,
+          readingTime: readingTime(blog.html),
+          component: blog.vue.component,
+          fullPath,
+          discussLink: `https://twitter.com/search?q=${encodeURIComponent(
+            fullPath
+          )}`,
+          editLink: `https://github.com/jefrydco/jefrydco/edit/master/${editPath}`
         }
-      })()
+      }
     } catch (error) {
       this.$router.replace('/blog')
     }

from frontmatter-markdown-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.