NEK-RA / nek-ra.github.io

Personal blog and project list built with NuxtJS, it's content module and Vuetify UI framework. Builds and deploys are automated by Github Actions.
https://nek-ra.github.io
2 stars 1 forks source link

Solve problem with Vuetify components inside markdown files #4

Open NEK-RA opened 3 years ago

NEK-RA commented 3 years ago

Problem

WARNING: next commented code is REQUIRED for static generation for Vuetify components rendered inside markdown files

Related issues:

As I understand: Vuetify loader doesn't check content of markdown files, that's why while runnin nuxt generate Vuetify components (that may be used in any component without import) are not rendered while used inside markdown files. I.e. v-alert which was used in blog to mark some text as warning and etc. At nuxt dev mode Vuetify component are rendered correctly because treeshake is disabled for development mode

This problem solved by two ways:

  1. disabling treeshake
  2. importing components inside template which render markdown content

Finaly second way works for nuxt generate and static content is renedered correctly, but if this code is used while using nuxt dev, development server will return error about "Unexpected token 'export'" when I visit page that displays markdown with Vuetify components.

P.S.: currently I used only "v-alert" component from Vuetify. If any more components will be used, don't forget to add them here!

import Vue from 'vue'
import { VAlert } from 'vuetify/lib'
Vue.component('VAlert', VAlert)

Status

Searching the way to avoid always comment/uncomment code for static generation

NEK-RA commented 3 years ago

Question created on Stackoverflow - https://stackoverflow.com/questions/66473779/

NEK-RA commented 3 years ago

Problem solved by wrapping v-alert component in my own version with it's basic props, thanks to answer on StackOverflow

At least it feels more valid than previous way, so I hope that's finally solved. Issue will stay opened for those who can approve/disapprove this solution as valid