Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update related documents when images change #30

Closed
davestewart opened this issue Apr 16, 2023 · 1 comment · Fixed by #31
Closed

Update related documents when images change #30

davestewart opened this issue Apr 16, 2023 · 1 comment · Fixed by #31
Labels
enhancement New feature or request

Comments

@davestewart
Copy link
Owner

davestewart commented Apr 16, 2023

Background

With the current watch system, images reload in the browser when they are changed.

However, any owning document is not updated, so if the image size changes, the document will still display the image at the old size, until the document itself is resaved.

Proposal

The only way for content documents to be successfully updated, would be to store a reverse lookup of which images are in which documents:

{
  'path/to/asset': {
    ...
    documents: [
      'source:path:to:doc_1',
      'source:path:to:doc_2',
    ]
  }
}

When documents are parsed:

  • for any found assets, the document id is inserted into the asset's metadata

When images are changed:

  • the image asset index is updated with the new metadata
  • related documents should be are re-parsed, updating image sizes in matching paths

When assets are deleted or moved:

  • the document list for each individual asset should be modified
  • related documents should be re-parsed, replacing old asset paths with the new asset paths

The thing to remember about moves is that they are reported by chokidar as a delete then an update, so does this change how paths should be rewritten, or is this only a concern for the user?

Also, it's possible that document moves would need to trigger this as well (should check if moves trigger the parsing hook).

Also, note that this only needs to happen if image size hints are on.

Otherwise, the image size should update automatically.

Notes

Consider if this would create problems if the related documents are open but not saved.

The target documents would need to be reloaded. Check live-reload section of #18 to see how this might be done.

@davestewart
Copy link
Owner Author

davestewart commented Apr 17, 2023

It looks like the refresh functionality is not going to work right now, as Nuxt Content is already refreshing saved content, even though it is ignored.

@davestewart davestewart linked a pull request Apr 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant