This is a simple weather widget I made to use in my Notion page. By default, this widget is set up to display the weather in Nairobi, but it can easily be customized to display the weather in any location.
To customize the widget for your location, you will need to make changes to the src/script.js
file. Follow these steps:
-
Go to https://weatherwidget.io/ and create a new weather widget by entering your city and adjusting the number of days you want to display.
-
Copy the weather code generated by the website.
-
Open the
src/script.js
file in a code editor.
Look for the following line of code:
`el.innerHTML = '<a class="weatherwidget-io" href="https://forecast7.com/en/n1d2936d82/nairobi/" data-label_1="NAIROBI" data-label_2="HOME" data-font="Noto Serif" data-icons="Climacons Animated" data-theme="original" data-basecolor="#dfd4e9" data-shadow="#ffffff" data-textcolor="#4b4747" data-highcolor="#4b4747" data-lowcolor="#4b4747" data-suncolor="#ffffff" data-cloudfill="#c2e4fc" data-raincolor="#163664">NAIROBI HOME</a>';`
-
Replace the URL in the href attribute with the URL generated by the weather widget website.
-
Replace the values of
data-label_1
anddata-label_2
with your desired labels for the widget. -
If you want to change the font, icons, or colors of the widget, you can adjust the corresponding
data-*
attributes. -
Save the
src/script.js
file. -
Open
index.html
in a web browser to see the updated weather widget.
To run the widget locally, you will need to have Node.js installed on your computer. Once you have installed Node.js, follow these steps:
-
Clone this repository to your local machine.
-
Open a terminal and navigate to the root directory of the repository.
-
Run the following command to install the dependencies:
npm install
-
Run the following command to build the widget:
npm run build
This will create a dist folder with the built widget files.
-
Open the
index.html
file in a web browser to view the widget.
To deploy the widget, you can use GitHub Pages. Follow these steps:
-
Go to the "Settings" tab of your repository.
-
Scroll down to the "GitHub Pages" section.
-
Under "Source", select "main branch" (or "master").
-
Click "Save".
-
Wait for a few seconds for the changes to take effect.
-
Your widget should now be accessible at https://your-username.github.io/weather-widget-notion/.
To use the widget in a Notion page, follow these steps:
-
Open the page where you want to add the widget.
-
Click the "+" button to add a new block.
-
Select "Embed" from the list of block types.
-
Copy and paste the deployed link into the embed block.
-
The widget should now be visible in your notion. Resize it however you see fit.