strapi / strapi-starter-nuxt-blog

Strapi Starter Nuxt Blog
https://strapi.io/blog/build-a-blog-using-nuxt-strapi-and-apollo
MIT License
181 stars 64 forks source link

Feature request : handle media URLs in post content #51

Open ElisePatrikainenIAD opened 3 years ago

ElisePatrikainenIAD commented 3 years ago

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.