preaction / Statocles

Static website CMS
http://preaction.me/statocles
Other
84 stars 33 forks source link

Don't rewrite anchor-only urls during index page rewrites #555

Closed jberger closed 6 years ago

jberger commented 6 years ago

When anchor-only hrefs are modified to point to some other page this obviously breaks their intent to link to the current page.

Fixes #554

preaction commented 6 years ago

The anchor is not always on the same page. If it's behind a fold (---), it would be on the next page, so we would have to rewrite the link in that case.

Also, the anchor isn't required to be unique on the page. If its taken to the internal blog post page, that's easy to deal with: It's in one file and the author can be asked to deal with that (we could even detect the problem and notify them). If it's in the list of blog posts, though, that's harder to deal with: all the blog posts in the list need to be checked for anchor uniqueness, and it's a lot harder to detect since it might only happen in a certain tag list page.

These are both solvable problems:

  1. We can check to see if the id or name exists in the content that we're about to add to the list view and rewrite if it isn't
  2. We can make the anchors left on the list view more unique by prefixing the blog post date or some other generated, persistent identifier

But, right now, it's more cautious to just rewrite the link assuming it won't be displayed on the list view, even if the individual blog pages aren't intended to be shown.

preaction commented 6 years ago

Okay, sorry, this isn't about blog index, but about the site index. This should work then, thanks!