maxime1992 / dev.to

[Template] My dev.to articles
59 stars 12 forks source link

Make basePath customizable #4

Open SigmundurMorkore opened 5 years ago

SigmundurMorkore commented 5 years ago

I'd love to be able to use this with NetlifyCMS. But NetlifyCMS does not use actual relative paths, which results in a weird url when it's parsed by dev-to-git.

The solution is to not rely on the markdown file's basePath, but I suggest making it configurable.

if (path) {
        const basePath: string = 'static'; // This solves my issue, but actual solution might make this customizable?
        const assetPath = path.substr(2);

        localImagesToReplace.push({
          localImage: image,
          remoteImage: `![${alt || ''}](https://raw.githubusercontent.com/${this.articleConfig.repository.username}\/${
            this.articleConfig.repository.name
          }/master/${basePath}/${assetPath}${title ? ` '${title}'` : ``})`,
        });
      }

I of course completely understand if you don't want to implement this. This package is still super awesome :)