sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
5k stars 346 forks source link

Is there a configuration based way to prevent removal of file extensions... #604

Closed StingyJack closed 4 years ago

StingyJack commented 7 years ago

... or to have harp correct the hyperlinks that may be in a document if it has to rewrite them?

The problem is that it currently harpjs breaks my links. If I have these two markdown files

file1.md

#Has some content
Has a [link](./file2.md) to another markdown file

file2.md

#Has something else

Harp converts the files to be accessible at server/site/file1 and server/site/file2, but the link in file1 is still pointed at "file2.md".

I think the renaming is intentional, but I would have expected it to fix the linkages also. I would like to avoid having to author in the dark or constantly fixup links. Is there a way to make this work?

alfonso-presa commented 6 years ago

I know this is and old question, but it might help someone else.

I solved it in my ejs template by just replacing <%- yield %> for <%- yield.replace(/\.md/g,'.html') %>. I know it's an ugly hack as it might collide with non link texts....fine tunning the regexp or using a more specific replacement might help.