├── img └── favicon.png ├── .github └── workflows │ └── azure-static-web-apps-ambitious-rock-09e1c9b0f.yml ├── CONTRIBUTING.md ├── app.js ├── README.md ├── index.html └── style.css /img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imhardikdesai/news-website/HEAD/img/favicon.png -------------------------------------------------------------------------------- /.github/workflows/azure-static-web-apps-ambitious-rock-09e1c9b0f.yml: -------------------------------------------------------------------------------- 1 | name: Azure Static Web Apps CI/CD 2 | 3 | on: 4 | push: 5 | branches: 6 | - New-Public-Insorts-Api 7 | pull_request: 8 | types: [opened, synchronize, reopened, closed] 9 | branches: 10 | - New-Public-Insorts-Api 11 | 12 | jobs: 13 | build_and_deploy_job: 14 | if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') 15 | runs-on: ubuntu-latest 16 | name: Build and Deploy Job 17 | steps: 18 | - uses: actions/checkout@v2 19 | with: 20 | submodules: true 21 | - name: Build And Deploy 22 | id: builddeploy 23 | uses: Azure/static-web-apps-deploy@v1 24 | with: 25 | azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_ROCK_09E1C9B0F }} 26 | repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) 27 | action: "upload" 28 | ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### 29 | # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig 30 | app_location: "/" # App source code path 31 | api_location: "" # Api source code path - optional 32 | output_location: "" # Built app content directory - optional 33 | ###### End of Repository/Build Configurations ###### 34 | 35 | close_pull_request_job: 36 | if: github.event_name == 'pull_request' && github.event.action == 'closed' 37 | runs-on: ubuntu-latest 38 | name: Close Pull Request Job 39 | steps: 40 | - name: Close Pull Request 41 | id: closepullrequest 42 | uses: Azure/static-web-apps-deploy@v1 43 | with: 44 | azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_ROCK_09E1C9B0F }} 45 | action: "close" 46 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to News Website 2 | 3 | Welcome to News Website! We appreciate your interest in contributing to our project. Whether you want to report a bug, suggest an improvement, or contribute code, please take a moment to read the following guidelines. 4 | 5 | ## Table of Contents 6 | 7 | - [Code of Conduct](#code-of-conduct) 8 | - [Reporting Bugs](#reporting-bugs) 9 | - [Contributing Code](#contributing-code) 10 | - [Commit Guidelines](#commit-guidelines) 11 | - [Pull Requests](#pull-requests) 12 | 13 | ## Code of Conduct 14 | 15 | Before getting started, please review our [Code of Conduct](CODE_OF_CONDUCT.md). We expect all contributors to adhere to this code to ensure a welcoming and respectful environment. 16 | 17 | ## Reporting Bugs 18 | 19 | If you encounter a bug or issue with News Website, please [create a new issue](link-to-issue-tracker) on our issue tracker. Be sure to include: 20 | 21 | - A clear and descriptive title. 22 | - Detailed steps to reproduce the bug. 23 | - Information about your environment (e.g., operating system, browser, or version of the project). 24 | 25 | ## Contributing Code 26 | 27 | We welcome code contributions from the community. To get started: 28 | 29 | 1. Fork the repository to your GitHub account. 30 | 2. Clone your fork to your local machine. 31 | 3. Create a new branch for your changes: `git checkout -b your-feature-name`. 32 | 4. Make your changes and test them thoroughly. 33 | 5. Commit your changes. 34 | 6. Push your changes to your fork: `git push origin your-feature-name`. 35 | 7. Create a pull request against the `main` branch of the main repository. 36 | 37 | ## Getting Started 38 | 39 | If you're new to News Website, you can explore all features and give us feedback at hardikdesaitech@gmail.com 40 | 41 | ## Commit Guidelines 42 | 43 | To keep our commit history clean and well-organized. Please adhere to these guidelines when making commits. 44 | 45 | ## Pull Requests 46 | 47 | When creating a pull request, make sure it includes: 48 | 49 | - A clear and concise title. 50 | - A description of the changes you've made and the problem it solves. 51 | - Any relevant issue references. 52 | 53 | Our maintainers will review your pull request, provide feedback, and merge it once it's ready. 54 | 55 | Thank you for your contributions! 56 | 57 | News Website Team 58 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const darkModeToggle = document.getElementById("darkModeToggle"); 2 | const body = document.body; 3 | document.getElementById( 4 | "footerText" 5 | ).innerHTML = `Copyright ©${new Date().getFullYear()} Hardik Desai`; 6 | // Function to toggle dark mode based on user preference 7 | function toggleDarkMode() { 8 | if (darkModeToggle.checked) { 9 | body.classList.add("dark-mode"); 10 | } else { 11 | body.classList.remove("dark-mode"); 12 | } 13 | } 14 | 15 | // Event listener for dark mode toggle button 16 | darkModeToggle.addEventListener("change", toggleDarkMode); 17 | 18 | // Function to check and set initial dark mode state based on user preferences 19 | function setInitialDarkMode() { 20 | const prefersDarkMode = window.matchMedia( 21 | "(prefers-color-scheme: dark)" 22 | ).matches; 23 | 24 | if (prefersDarkMode) { 25 | body.classList.add("dark-mode"); 26 | darkModeToggle.checked = true; 27 | } 28 | } 29 | 30 | // Call the function to set initial dark mode state 31 | //setInitialDarkMode(); 32 | 33 | let newsBox = document.getElementById("newsBox"); 34 | let spinner = document.getElementById("spinner"); 35 | let newsCategory = [ 36 | "national", 37 | "business", 38 | "sports", 39 | "world", 40 | "politics", 41 | "technology", 42 | "startup", 43 | "entertainment", 44 | "miscellaneous", 45 | "hatke", 46 | "science", 47 | "automobile", 48 | ]; 49 | 50 | // Create XMLHttpRequest Object 51 | const xhr = new XMLHttpRequest(); 52 | 53 | function sendCategory(index) { 54 | getNews(newsCategory[index]); 55 | } 56 | getNews("all"); 57 | 58 | function getNews(newsCategoryName) { 59 | xhr.open("GET", `https://saurav.tech/NewsAPI/everything/cnn.json`, true); 60 | 61 | xhr.getResponseHeader("Content-type", "application/json"); 62 | 63 | xhr.onload = function () { 64 | if (this.status === 200) { 65 | let json = JSON.parse(this.responseText); 66 | let data = json.articles; 67 | 68 | let newsHTML = ""; 69 | 70 | for (key in data) { 71 | let news = `
${data[key].content}
85 | Read more.. 88 |46 | | |───Img 47 | │ └───Favicon 48 | ├───Components 49 | │ ├───Navbar 50 | │ └───Header of Website 51 | ├───News Box 52 | │ ├───Image of News 53 | │ ├───News Title 54 | │ ├───News Discription 55 | │ ├───Read More 56 | │ └───Date & Time 57 | ├───Footer 58 |59 |