strapi-starter-nuxt-blog icon indicating copy to clipboard operation
strapi-starter-nuxt-blog copied to clipboard

Feature request : handle media URLs in post content

Open ElisePatrikainenIAD opened this issue 2 years ago • 0 comments

Thank you for this starter. I wanted to suggest a feature: I think it could be useful to provide a helper that parses posts contents and adds the strapi server base URL to the media relatives paths (otherwise, media in posts contents can't be loaded).

For example (using String.replace to be compatible with Node.js 14 and below) :

// media.js
export function parseStrapiMediaUrls(content) {
  return content.replace(new RegExp("]\\(/uploads/", "g"), `](${process.env.strapiBaseUri}/uploads/`);
}

I tried to make a PR but apparently I don't have the access rights for that. Otherwise I would be glad to do it.

ElisePatrikainenIAD avatar Sep 04 '21 16:09 ElisePatrikainenIAD