An awesome Tech News Reader powered with Hacker News service.
Try the app!
Table of Contents
The goal of the project is to deliver an application to democratize the sharing of information in the tech field, through the use of the Hacker News service.
At its startup the application displays the list of the latest news available by showing title, link, author and date of the story. It contacts APIs of the external Hacker News service to retrieve the list of latest news IDs. For each ID, the application recalls another API of the Hacker News service to obtain the information to be displayed such as title, link, author and date of the news.
Note: the first API useful to get the list of the latest news (newstories) returns about 500 elements. In order to avoid performance problems, after having retrieved the list of the latest news, the application will show only details of the first 10 news. Through a button Load more
the application will allow the user to go and view information of the next 10 news.
The function used to call APIs is in the index.js
file, in the js
folder; the main button features and a function to show release time of each story referred to current nowtime are developed in the services
folder.
A golden shadow, developed in scrollShadow.js
, shows up to inform the user that there are new available stories above/below her/his viewport.
JavaScript is basically all I used to bootstrap this project. I bundled the app using Webpack. I used Axios for simpler API calls, Lodash to prevent unreadable properties during API calls, and Dotenv to recall hidden environment variables (as a studying purpose since HN API's are still public)
Html5
Css3
Sass
JavaScript ES6
Axios
![lodash](https://private-user-images.githubusercontent.com/129901135/251822913-6cfc745a-9d1c-4fbe-b4bd-0b04f744923e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMTk2MDgsIm5iZiI6MTczOTExOTMwOCwicGF0aCI6Ii8xMjk5MDExMzUvMjUxODIyOTEzLTZjZmM3NDVhLTlkMWMtNGZiZS1iNGJkLTBiMDRmNzQ0OTIzZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQxNjQxNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zYmI0ZWJiYjI0N2IyYmQ4OGVjMDM0MjQ4NjdiYTE0YjkxM2M0MGZjZDMxMzRiZDZhNDRlZjQzZWI2ZDE0YjU1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Gmb1nNM5ZohA0sGnto-7k9zBykw15S4ZXZ6iYvOY0yw)
![axios](https://private-user-images.githubusercontent.com/129901135/250973645-8c11269d-5b85-4ac4-aeca-f72770507c1f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMTk2MDgsIm5iZiI6MTczOTExOTMwOCwicGF0aCI6Ii8xMjk5MDExMzUvMjUwOTczNjQ1LThjMTEyNjlkLTViODUtNGFjNC1hZWNhLWY3Mjc3MDUwN2MxZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQxNjQxNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wYjI2MzZjMmYyNzJiNzUzZmZhZTQwMTBiMTNhM2FlMmZlNzcwY2NhZGIzMTA0NTI5YmNiYjA0MjNjNDZmMjMyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.F9F5A45MLI5wYdmIahsfQfuzrSJkGE1xT1duUvFdv0A)
![webpack](https://private-user-images.githubusercontent.com/129901135/250972877-651caf8c-af6c-4b6e-89d0-0af5538bfc5b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMTk2MDgsIm5iZiI6MTczOTExOTMwOCwicGF0aCI6Ii8xMjk5MDExMzUvMjUwOTcyODc3LTY1MWNhZjhjLWFmNmMtNGI2ZS04OWQwLTBhZjU1MzhiZmM1Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQxNjQxNDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mYzE5M2E3OTk4NmUwMDI2M2ZkYmNjYTY3M2I4MmRmZjZkMGNhZTY4YTc2OGRhNmEwNmZjNTFhZTM1OWNlMjNjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.3_MO6I8c45OXBwcbrDiQ9rBc7FTj7PgJARRiYapORhU)
This project was bootstrapped with Webpack, Axios, Lodash and Dotenv.
I published this code at the link https://hackernews-api-react-egidiosalinaro.netlify.app/ so you can use it, but if you want you can also install it in your device using Webpack:
You need to have Node and npm installed. You can check the version you have installed by running:
npm -v
Once downloaded this repo, in the project directory, you can run:
npm init -y
Then you will need to
- install webpack
npm i -D webpack webpack-cli
- initialize the project
npx webpack init
While answering initialization questions, make sure you select the SASS option for style compiling, since this is how I styled this app.
To use all the code's functionalities you will need to install also Axios (for API calls), Lodash (with the _.get function to prevent unreadable properties during API calls) and Dotenv (to recall environment variables from a .env
file) libraries.
Use these commands in terminal:
npm install axios
npm i --save lodash
npm install dotenv --save
At this stage you can run
npm run build
to build the app for production in the dist
folder, and
npm run serve
to see the app in action in your local machine.
At its startup the application displays a list of the latest 10 tech news available by showing title, link, author and release date of each story. The user can read them by clicking on the title or on the relative open-in-a-new-tab button. User can decide to load ten more stories with the bottom LOAD MORE
button, or to refresh the page using the NEW STORIES
button.
Golden shadows shows up from the header and the footer to inform the user that there are new available stories above/below her/his viewport.
- call
newstories
API - call APIs for each stories' details
- create
.env
file and insert it in the.gitignore
list - time functions
-
Load More
button to call 10 new stories - styles improvements
- shadows to inform about new available stories
- colors and buttons images
Distributed under the MIT License. See LICENSE
for more information.