Skip to content

Commit 37d7fbc

Browse files
committed
Updates
1 parent 57e4838 commit 37d7fbc

19 files changed

+74
-74
lines changed

asset-manifest.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"files": {
3-
"main.css": "/static/css/main.5097ff90.css",
4-
"main.js": "/static/js/main.b21daf61.js",
3+
"main.css": "/static/css/main.76e61332.css",
4+
"main.js": "/static/js/main.697fe5e8.js",
55
"static/js/453.f568ff1d.chunk.js": "/static/js/453.f568ff1d.chunk.js",
66
"static/media/border.jpg": "/static/media/border.b7869a9ea7ccd009873c.jpg",
77
"static/media/parchment.png": "/static/media/parchment.c4af92656f29dc66bd67.png",
@@ -10,12 +10,12 @@
1010
"static/media/slick.ttf": "/static/media/slick.c94f7671dcc99dce43e2.ttf",
1111
"static/media/slick.woff": "/static/media/slick.295183786cd8a1389865.woff",
1212
"index.html": "/index.html",
13-
"main.5097ff90.css.map": "/static/css/main.5097ff90.css.map",
14-
"main.b21daf61.js.map": "/static/js/main.b21daf61.js.map",
13+
"main.76e61332.css.map": "/static/css/main.76e61332.css.map",
14+
"main.697fe5e8.js.map": "/static/js/main.697fe5e8.js.map",
1515
"453.f568ff1d.chunk.js.map": "/static/js/453.f568ff1d.chunk.js.map"
1616
},
1717
"entrypoints": [
18-
"static/css/main.5097ff90.css",
19-
"static/js/main.b21daf61.js"
18+
"static/css/main.76e61332.css",
19+
"static/js/main.697fe5e8.js"
2020
]
2121
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en" class="dark"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="icon" type="image/svg+xml" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="alternate" type="application/rss+xml" title="Fezcodex RSS Feed" href="/rss.xml"/><meta name="description" content="codex by fezcode..."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Arvo&family=Inter&family=Playfair+Display&display=swap" rel="stylesheet"><title>fezcodex</title><script defer="defer" src="/static/js/main.b21daf61.js"></script><link href="/static/css/main.5097ff90.css" rel="stylesheet"></head><body class="bg-slate-950"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1+
<!doctype html><html lang="en" class="dark"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><link rel="icon" type="image/svg+xml" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="alternate" type="application/rss+xml" title="Fezcodex RSS Feed" href="/rss.xml"/><meta name="description" content="codex by fezcode..."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet"><link href="https://fonts.googleapis.com/css2?family=Arvo&family=Inter&family=Playfair+Display&display=swap" rel="stylesheet"><title>fezcodex</title><script defer="defer" src="/static/js/main.697fe5e8.js"></script><link href="/static/css/main.76e61332.css" rel="stylesheet"></head><body class="bg-slate-950"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

posts/gemini-explains-how-hooks-work-with-toast-component.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ This file defines a custom hook called `useToast`. It uses `useContext` to acces
3636

3737
```javascript
3838
import { useContext } from 'react';
39-
import { ToastContext } from '../components/ToastProvider';
39+
import { ToastContext } from '../components/ToastContext';
4040

4141
export const useToast = () => {
4242
return useContext(ToastContext);
4343
};
4444
```
4545

46-
### `src/components/ToastProvider.js`
47-
This file defines the `ToastProvider` component, which manages the state of the toasts. It uses `useState` to hold the `toasts` array, and provides `addToast` and `removeToast` functions. It also renders the `Toast` components.
46+
### `src/components/ToastContext.js`
47+
This file defines the `ToastContext` component, which manages the state of the toasts. It uses `useState` to hold the `toasts` array, and provides `addToast` and `removeToast` functions. It also renders the `Toast` components.
4848

4949
```javascript
5050
import React, { createContext, useState, useCallback } from 'react';
@@ -54,7 +54,7 @@ export const ToastContext = createContext();
5454

5555
let id = 0;
5656

57-
export const ToastProvider = ({ children }) => {
57+
export const ToastContext = ({ children }) => {
5858
const [toasts, setToasts] = useState([]);
5959

6060
const addToast = useCallback((toast) => {
@@ -135,23 +135,23 @@ export default Toast;
135135
```
136136

137137
### `src/App.js`
138-
The main component of the application. The `ToastProvider` wraps the entire application to make the toast functionality available everywhere.
138+
The main component of the application. The `ToastContext` wraps the entire application to make the toast functionality available everywhere.
139139

140140
```javascript
141141
import React from 'react';
142142
import { HashRouter as Router } from 'react-router-dom';
143143
import Layout from './components/Layout';
144144
import AnimatedRoutes from './components/AnimatedRoutes';
145-
import { ToastProvider } from './components/ToastProvider';
145+
import { ToastContext } from './components/ToastContext';
146146

147147
function App() {
148148
return (
149149
<Router>
150-
<ToastProvider>
150+
<ToastContext>
151151
<Layout>
152152
<AnimatedRoutes />
153153
</Layout>
154-
</ToastProvider>
154+
</ToastContext>
155155
</Router>
156156
);
157157
}
@@ -261,21 +261,21 @@ This file defines a custom hook called `useToast`.
261261

262262
```javascript
263263
import { useContext } from 'react';
264-
import { ToastContext } from '../components/ToastProvider';
264+
import { ToastContext } from '../components/ToastContext';
265265

266266
export const useToast = () => {
267267
return useContext(ToastContext);
268268
};
269269
```
270270

271-
- `useContext(ToastContext)`: This line uses the `useContext` hook to access the data provided by the `ToastContext`. The `ToastContext` is created in `ToastProvider.js`.
271+
- `useContext(ToastContext)`: This line uses the `useContext` hook to access the data provided by the `ToastContext`. The `ToastContext` is created in `ToastContext.js`.
272272
- `export const useToast`: This line exports the `useToast` hook so that it can be used in other components.
273273

274274
This custom hook provides a simple way for any component to access the `addToast` and `removeToast` functions without having to pass them down as props.
275275

276-
### `src/components/ToastProvider.js`
276+
### `src/components/ToastContext.js`
277277

278-
This file defines the `ToastProvider` component, which is responsible for managing the state of the toasts.
278+
This file defines the `ToastContext` component, which is responsible for managing the state of the toasts.
279279

280280
```javascript
281281
import React, { createContext, useState, useCallback } from 'react';
@@ -285,7 +285,7 @@ export const ToastContext = createContext();
285285

286286
let id = 0;
287287

288-
export const ToastProvider = ({ children }) => {
288+
export const ToastContext = ({ children }) => {
289289
const [toasts, setToasts] = useState([]);
290290

291291
const addToast = useCallback((toast) => {
@@ -378,31 +378,31 @@ export default Toast;
378378

379379
### `src/App.js`
380380

381-
This is the main component of the application. The only change here was to wrap the entire application with the `ToastProvider`.
381+
This is the main component of the application. The only change here was to wrap the entire application with the `ToastContext`.
382382

383383
```javascript
384384
import React from 'react';
385385
import { HashRouter as Router } from 'react-router-dom';
386386
import Layout from './components/Layout';
387387
import AnimatedRoutes from './components/AnimatedRoutes';
388-
import { ToastProvider } from './components/ToastProvider';
388+
import { ToastContext } from './components/ToastContext';
389389

390390
function App() {
391391
return (
392392
<Router>
393-
<ToastProvider>
393+
<ToastContext>
394394
<Layout>
395395
<AnimatedRoutes />
396396
</Layout>
397-
</ToastProvider>
397+
</ToastContext>
398398
</Router>
399399
);
400400
}
401401

402402
export default App;
403403
```
404404

405-
- `<ToastProvider>`: By wrapping the `Layout` component with the `ToastProvider`, we make the `addToast` and `removeToast` functions available to all the components in the application.
405+
- `<ToastContext>`: By wrapping the `Layout` component with the `ToastContext`, we make the `addToast` and `removeToast` functions available to all the components in the application.
406406

407407
### `src/pages/BlogPostPage.js`
408408

posts/react-of-fezcode/001-project-overview.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The project follows a typical React application structure, with key directories
3737
## How it Works (High-Level)
3838

3939
1. **Entry Point (`src/index.js`):** The application starts by rendering the main `App` component into the `index.html` file.
40-
2. **Main Application (`src/App.js`):** The `App` component sets up client-side routing using `HashRouter`, defines the overall layout, and manages global contexts like the `ToastProvider`.
40+
2. **Main Application (`src/App.js`):** The `App` component sets up client-side routing using `HashRouter`, defines the overall layout, and manages global contexts like the `ToastContext`.
4141
3. **Routing (`react-router-dom`):** `AnimatedRoutes` (likely a component that uses `react-router-dom`'s `Routes` and `Route` components) handles mapping URLs to specific page components.
4242
4. **Content Fetching:** Blog posts and other dynamic content are fetched from `.txt` files located in the `public/` directory. Metadata for these posts is often stored in corresponding `.json` files (e.g., `public/posts/posts.json`). The blog page now includes a search functionality to easily find posts by title or slug.
4343
5. **Styling (`Tailwind CSS`):** The UI is styled primarily using Tailwind CSS utility classes, with some custom CSS if needed.

posts/react-of-fezcode/004-app-js-main-component.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import React from 'react';
77
import { HashRouter as Router } from 'react-router-dom';
88
import Layout from './components/Layout';
99
import AnimatedRoutes from './components/AnimatedRoutes';
10-
import { ToastProvider } from './components/ToastProvider';
10+
import { ToastContext } from './components/ToastContext';
1111
import ScrollToTop from './components/ScrollToTop';
1212

1313
function App() {
1414
return (
1515
<Router>
1616
<ScrollToTop />
17-
<ToastProvider>
17+
<ToastContext>
1818
<Layout>
1919
<AnimatedRoutes />
2020
</Layout>
21-
</ToastProvider>
21+
</ToastContext>
2222
</Router>
2323
);
2424
}
@@ -51,9 +51,9 @@ import AnimatedRoutes from './components/AnimatedRoutes';
5151
* **`import AnimatedRoutes from './components/AnimatedRoutes';`**: Imports the `AnimatedRoutes` component. This component is responsible for defining the application's routes and likely incorporates animation for page transitions, possibly using a library like `framer-motion`.
5252

5353
```javascript
54-
import { ToastProvider } from './components/ToastProvider';
54+
import { ToastContext } from './components/ToastContext';
5555
```
56-
* **`import { ToastProvider } from './components/ToastProvider';`**: Imports the `ToastProvider` component. This component is part of React's Context API pattern. It makes a `toast` (a small, temporary notification) functionality available to all its child components without having to pass props down manually at every level.
56+
* **`import { ToastContext } from './components/ToastContext';`**: Imports the `ToastContext` component. This component is part of React's Context API pattern. It makes a `toast` (a small, temporary notification) functionality available to all its child components without having to pass props down manually at every level.
5757

5858
```javascript
5959
import ScrollToTop from './components/ScrollToTop';
@@ -67,11 +67,11 @@ function App() {
6767
return (
6868
<Router>
6969
<ScrollToTop />
70-
<ToastProvider>
70+
<ToastContext>
7171
<Layout>
7272
<AnimatedRoutes />
7373
</Layout>
74-
</ToastProvider>
74+
</ToastContext>
7575
</Router>
7676
);
7777
}
@@ -84,7 +84,7 @@ function App() {
8484

8585
* **`<ScrollToTop />`**: This component is rendered directly inside the `Router`. Its effect (scrolling to top on route change) will apply globally to the application.
8686

87-
* **`<ToastProvider>`**: This component wraps the `Layout` and `AnimatedRoutes`. This means that any component rendered within the `Layout` or `AnimatedRoutes` will have access to the toast functionality provided by the `ToastProvider` via the `useContext` hook.
87+
* **`<ToastContext>`**: This component wraps the `Layout` and `AnimatedRoutes`. This means that any component rendered within the `Layout` or `AnimatedRoutes` will have access to the toast functionality provided by the `ToastContext` via the `useContext` hook.
8888

8989
* **`<Layout>`**: This component defines the common structure (e.g., header, footer, navigation) that will be present on most pages. It wraps the `AnimatedRoutes` component, meaning the routed content will be displayed within this layout.
9090

@@ -99,4 +99,4 @@ export default App;
9999

100100
## Summary
101101

102-
`src/App.js` orchestrates the main structure and global functionalities of the application. It sets up routing, provides global context for notifications, and defines the overarching layout, ensuring a consistent user experience across different pages.
102+
`src/App.js` orchestrates the main structure and global functionalities of the application. It sets up routing, provides global context for notifications, and defines the overarching layout, ensuring a consistent user experience across different pages.

posts/react-of-fezcode/008-react-context-usecontext.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ The Context API consists of three main parts:
1616

1717
## Example: Toast Notification System
1818

19-
This project uses the Context API to manage and display toast notifications globally. Let's examine `src/components/ToastProvider.js` and `src/hooks/useToast.js`.
19+
This project uses the Context API to manage and display toast notifications globally. Let's examine `src/components/ToastContext.js` and `src/hooks/useToast.js`.
2020

21-
### `src/components/ToastProvider.js` (The Provider)
21+
### `src/components/ToastContext.js` (The Provider)
2222

2323
```javascript
2424
import React, { createContext, useState, useCallback } from 'react';
@@ -28,7 +28,7 @@ export const ToastContext = createContext();
2828

2929
let id = 0; // Simple counter for unique toast IDs
3030

31-
export const ToastProvider = ({ children }) => {
31+
export const ToastContext = ({ children }) => {
3232
const [toasts, setToasts] = useState([]); // State to hold active toasts
3333

3434
const addToast = useCallback((toast) => {
@@ -69,18 +69,18 @@ export const ToastProvider = ({ children }) => {
6969
**Explanation:**
7070

7171
1. **`export const ToastContext = createContext();`**: A Context object named `ToastContext` is created. This object will be used by both the Provider and the Consumer.
72-
2. **`ToastProvider` Component**: This is a functional component that will wrap parts of your application (as seen in `App.js`).
72+
2. **`ToastContext` Component**: This is a functional component that will wrap parts of your application (as seen in `App.js`).
7373
* **`const [toasts, setToasts] = useState([]);`**: Manages the array of active toast notifications using `useState`.
7474
* **`addToast` and `removeToast` functions**: These functions are responsible for adding new toasts to the `toasts` array and removing them. They are wrapped in `useCallback` to prevent unnecessary re-creations, which is an optimization for performance.
7575
* **`<ToastContext.Provider value={{ addToast, removeToast }}>`**: This is the core of the Provider. It makes the `addToast` and `removeToast` functions available to any component that consumes `ToastContext` and is rendered within this Provider's tree. The `value` prop is crucial here.
76-
* **`{children}`**: This renders whatever components are passed as children to the `ToastProvider`. These children (and their descendants) will have access to the context value.
77-
* **Toast Rendering**: The `ToastProvider` also directly renders the actual `Toast` components based on the `toasts` state, positioning them in the top-right corner of the screen.
76+
* **`{children}`**: This renders whatever components are passed as children to the `ToastContext`. These children (and their descendants) will have access to the context value.
77+
* **Toast Rendering**: The `ToastContext` also directly renders the actual `Toast` components based on the `toasts` state, positioning them in the top-right corner of the screen.
7878

7979
### `src/hooks/useToast.js` (The Consumer Hook)
8080

8181
```javascript
8282
import { useContext } from 'react';
83-
import { ToastContext } from '../components/ToastProvider';
83+
import { ToastContext } from '../components/ToastContext';
8484

8585
export const useToast = () => {
8686
return useContext(ToastContext);
@@ -90,7 +90,7 @@ export const useToast = () => {
9090
**Explanation:**
9191

9292
1. **`import { useContext } from 'react';`**: Imports the `useContext` Hook from React.
93-
2. **`import { ToastContext } from '../components/ToastProvider';`**: Imports the `ToastContext` object that was created in `ToastProvider.js`.
93+
2. **`import { ToastContext } from '../components/ToastContext';`**: Imports the `ToastContext` object that was created in `ToastContext.js`.
9494
3. **`export const useToast = () => { ... };`**: This is a custom hook. Custom hooks are a powerful feature in React that allow you to extract reusable stateful logic from components. This `useToast` hook simplifies consuming the `ToastContext`.
9595
4. **`return useContext(ToastContext);`**: This line is where the magic happens. When `useContext(ToastContext)` is called, React looks up the component tree for the closest `ToastContext.Provider` and returns its `value` prop. In this case, it returns `{ addToast, removeToast }`.
9696

@@ -120,4 +120,4 @@ Any component that needs to display a toast simply imports and calls `useToast()
120120

121121
## Summary
122122

123-
The React Context API, combined with the `useContext` hook, provides an elegant solution for managing global state and sharing functions across your component tree, avoiding prop drilling and making your application's architecture cleaner and more maintainable. The toast notification system in this project is a prime example of its effective use.
123+
The React Context API, combined with the `useContext` hook, provides an elegant solution for managing global state and sharing functions across your component tree, avoiding prop drilling and making your application's architecture cleaner and more maintainable. The toast notification system in this project is a prime example of its effective use.

0 commit comments

Comments
 (0)