enochchau / mjml-preview.nvim

Get a realtime preview of MJML files with Neovim
MIT License
6 stars 0 forks source link

Improve documentation #1

Open ww-daniel-mora opened 1 year ago

ww-daniel-mora commented 1 year ago

Improve documentation and explain the expected mjml project structure for this plugin to work. At the moment I am unable to correctly render an mjml file and it is not clear what the plugin is doing from the documentation.

enochchau commented 1 year ago

Can you please provide steps to reproduce your issue?

You can view the debug log by adding the following code to your init.lua before loading this plugin.

vim.g.mjml_preview_debug = true
ww-daniel-mora commented 1 year ago

Okay I actually misunderstood what I was seeing and it was working but there are 3 improvements we should make.

  1. The iframe displays is very small. We should default the value to 100% width and some height like 1000px;
  2. There should be some way to configure the default iframe size
  3. Currently local assets cannot be rendered

This structure will not be able to load the local image.

email/
 - index.mjml
 - images/
   - some_img.png 

It looks like we are hitting this catch block https://github.com/ec965/mjml-preview.nvim/blob/main/app/src/index.js#L185 when another file is requested.

enochchau commented 1 year ago

The current architecture is to read your MJML file's content from the Neovim buffer rather than read the file directly. The web server isn't configured to serve arbitrary files in the filesystem.

enochchau commented 1 year ago

If you want to be able to serve files from any folder on your computer, we have a couple options:

  1. Create a setup function and add a configuration option that can point towards an assets folder.
  2. Add a parameter to MjmlPreviewToggle and MjmlPreviewOpen user commands to serve an assets folder.
  3. Use the buffer's file path as the root directory and serve all assets from that location.

'3' would work for your example file structure, but it would no longer work if we had a buffer that wasn't yet saved to disk.

ww-daniel-mora commented 1 year ago

I think we can implement 3 and then fall back to the "cwd" if the file is not saved.