PokeAPI / pokeapi.co

The PokéAPI documentation website
https://pokeapi.co
BSD 3-Clause "New" or "Revised" License
138 stars 52 forks source link

Edit this page #12

Open Naramsim opened 6 years ago

Naramsim commented 6 years ago

We could add in the footer an 'edit this page' link. So that if I am browsing the about page, clicking on this button will redirect me to https://github.com/PokeAPI/pokeapi.co/blob/master/src/pages/about.html.js

An example is vue: https://vuejs.org/v2/guide/ look at the footer

I think it can be done by looking at the URL the user is currently browsing and replacing the base URL with the Github's one. Something like:

`https://github.com/PokeAPI/pokeapi.co/tree/master/src/pages${window.location.pathname}.js`

This will also increase the popularity of this repo 😄

PS: @cmmartti why the about, the v1 and v2 files are named .html.js? While the others are only .js?

cmmartti commented 6 years ago

So that in the URL, files have *.html, while folders are just bare. That's the idea anyway (I forgot to do it with the status page). I got it from reactjs.org, which is also built on Gatsby. It's not strictly necessary and we can change it back if that's the consensus, but I liked the idea. I also set up redirects in the netlify.toml file, but those are not working while the site is hosted on Digital Ocean.

cmmartti commented 6 years ago

Re: the edit this page link, that's a great idea that we should definitely implement.

However, we can't use window.location.pathname, but we can use Gatsby's (React Router's) location object, which has the same structure. It can be passed into the LayoutFooter component from src/components/Layout.js.