Skip to content

feat: use mdcrenderer component and parsemarkdown util outside nuxt#154

Merged
farnabaz merged 10 commits intonuxt-content:mainfrom
adamdehaven:feat/use-outside-nuxt
Mar 7, 2024
Merged

feat: use mdcrenderer component and parsemarkdown util outside nuxt#154
farnabaz merged 10 commits intonuxt-content:mainfrom
adamdehaven:feat/use-outside-nuxt

Conversation

@adamdehaven
Copy link
Copy Markdown
Contributor

@adamdehaven adamdehaven commented Mar 4, 2024

Allow utilizing the MDCRenderer.vue component and parseMarkdown utility in a normal Vue app, outside Nuxt.

I've updated the @nuxtjs/mdc module in this PR along with updates to the primary README for usage instructions.

I've also created a CodeSandbox demo by building the package, running npm pack, and importing the changes into the sandbox via a local nuxtjs-mdc-local.tgz bundle.

MDCRenderer component rendering markdown and MDC

Please see the README file in the PR as well as the CodeSandbox for a usage example.

@farnabaz @antfu I'd appreciate some eyes on this; mainly around:

  1. Is defining import aliases in the host project's Vite config the best way to get around the Nuxt-specific imports that aren't needed? I don't like the host app having to include the aliases and the stubbed import file, but wasn't sure of another way of getting around Vite choking on the import paths. This is a bit fragile, as if any new imports are added in the future, a host project would have to add more aliases to its Vite config. I thought about refactoring at least these internal #mdc-* imports but wasn't sure of the downstream impact.
  2. I have syntax highlighting working by exporting a few of the remark and shiki utils that were previously internal (as @farnabaz and I discussed last week at Vue Amsterdam). Syntax highlighting works via the host project defining it's highlighter via the createShikiHighlighter util along with the rehypeHighlight and passing it into the parseMarkdown utility. This works great in my opinion, but just want to make sure this is good as a long-term solution?
  3. I have a TODO question in the fallback interface I'm providing in the MDCRenderer.vue setup function.

When merged, this will resolve #155.

@adamdehaven adamdehaven marked this pull request as ready for review March 5, 2024 01:28
Allow utilizing the MDCRenderer component and parseMarkdown utility in a normal Vue app.
@adamdehaven adamdehaven force-pushed the feat/use-outside-nuxt branch from ede0037 to 148b959 Compare March 5, 2024 01:29
@farnabaz
Copy link
Copy Markdown
Collaborator

farnabaz commented Mar 5, 2024

Thanks for the issue and PR @adamdehaven,
Generally looks good, I'll check these changes in your demo and see if we can improve it, to become even simpler.
Also, I did refactor MDCRenderer in #153.

As for example in README, I think it will be even better if we move them into docs/ and have a dedicated page for Using in Vue project

@adamdehaven
Copy link
Copy Markdown
Contributor Author

I'll check these changes in your demo and see if we can improve it, to become even simpler. Also, I did refactor MDCRenderer in #153.

Ah perfect; removing those imports will definitely simplify things in the host app. I was going to see about refactoring away the other #mdc-* imports as well but wasn't sure if that was desired.

As for example in README, I think it will be even better if we move them into docs/ and have a dedicated page for Using in Vue project

I can put together an example in the docs, but I couldn't get the docs site to work for me locally. What am I missing? 😬

@farnabaz let me know if I can help with anything; otherwise I'll wait to hear back from you in the next day or two

Comment thread README.md Outdated
Comment thread README.md Outdated
@farnabaz
Copy link
Copy Markdown
Collaborator

farnabaz commented Mar 6, 2024

I can put together an example in the docs, but I couldn't get the docs site to work for me locally. What am I missing?

Hmm, let's ignore it README is fine for now :)

@farnabaz
Copy link
Copy Markdown
Collaborator

farnabaz commented Mar 6, 2024

@adamdehaven I've updated your PR, do you mind checking in your project to confirm functionality?

@adamdehaven
Copy link
Copy Markdown
Contributor Author

@farnabaz I can confirm the changes work in my project locally, and I have also updated the Code Sandbox with the latest changes.

I also pushed a couple updates to the README (couple typos, and a few words on the new implementation).

@farnabaz farnabaz merged commit 3af5d5d into nuxt-content:main Mar 7, 2024
@adamdehaven adamdehaven deleted the feat/use-outside-nuxt branch March 7, 2024 02:30
@adamdehaven
Copy link
Copy Markdown
Contributor Author

@farnabaz any idea when the npm release will be published?

@farnabaz
Copy link
Copy Markdown
Collaborator

farnabaz commented Mar 7, 2024

I made a little change in runtime exports and just released new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow MDCRenderer and parseMarkdown usage outside of Nuxt

2 participants