HashLips / generative-art-opensource

Create generative art by using the canvas api and node js, feel free to contribute to this repo with new ideas.
MIT License
1.36k stars 695 forks source link

Prettier and Removing .png/.json from URL #104

Open leoddk opened 2 years ago

leoddk commented 2 years ago

So I have prettier installed as a Visual Studio add-on. Currently, I have to right-click and format with prettier on every json file I have made. Is there a way to automatically format any new json files with prettier before they are ever created?

My second question is one that was brought up in a previous video. How do you remove .png and .json from the URL name? I would love to just have users search /nft/1 or /nft/2 instead of /nft/1.png etc.

Appreciate anyone who can help!

Ponda1 commented 2 years ago

There is an extension called format files in vs code which formats all the files in your workspace by clicking it once. For the other question, im not experienced at this but i dont think theres a way to do that since the files stored on ipfs will always have an extension. I could be wrong though

leoddk commented 2 years ago

I found out how to remove any extension, specifically .png from your website URL. If you use a hosting platform such as bluehost and have access to the public_html folder then can access the hidden file called .htaccess. Once you are in there simply add this line of code to the file and save:

RewriteEngine On RewriteRule ^(wp-admin)($|/) - [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.png -f RewriteRule .* $0.png RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.png RewriteRule ^/?(.*)\.png$ /$1 [L,R=301] RewriteCond %{REQUEST_FILENAME}\.png -f RewriteRule ^/?(.*)$ /$1.png [L]

If you want to remove other file extensions such as .json then simply change all the .png extensions in the code to .json