MLEVN / mlevn.github.io

ML EVN - Yerevan machine learning community
https://mlevn.org
9 stars 19 forks source link

'redirect' layout #24

Closed bittlingmayer closed 6 years ago

bittlingmayer commented 6 years ago

Would be ideal to redirect mlevn.org/language to https://www.reddit.com/r/MLEVN/search?q=flair%3Alanguage&sort=new&restrict_sr=on and so on.

SGevorg commented 6 years ago

we can have mlevn.org/ in general redirecting to coresponding search query

bittlingmayer commented 6 years ago

True, better than hardcoding.

But because it's static there is no way to do it server-side.

We can make the 404.html grab location.pathname.

And we should make sure analytics loads fast on that page, so we get stats for those links.

bittlingmayer commented 6 years ago
<html>
  <head>
    <script>
      const flairs = window.location.pathname.split('/').filter(f => f);
      const query = flairs.map(f => encodeURIComponent('flair:' + f)).join('+');
      const url = 'https://www.reddit.com/r/MLEVN/search?restrict_sr=on&q=' + query;
      window.location.replace(url);
    </script>
  </head>
  <body>
  </body>
</html>

We could also split on +.

In which cases should we actually show a 404? For example if it ends with / it is probably not a query.

bittlingmayer commented 6 years ago

Done.

Try: mlevn.org/posts/language+startups

Also supports jobs, try:
mlevn.org/jobs/language