ToCode
Kanalga Telegramโda oโtish
ืืืคืื ืงืฆืจืื ืืืชืื ืชืื ืืืช ืื ืื ืคืจืง
Ko'proq ko'rsatish1 420
Obunachilar
+124 soatlar
+17 kunlar
-430 kunlar
Postlar arxiv
1 420
ืคืืื ืฆืืื (ืืืค ืืืืคืืฉ ืขืืืื)
ืืคืขืืื ืื ื ืืืคืฉ ืขืืืื ืฉืืืืืง ืืชืืืื ืืืืฉืืจืื ืฉืื. ืืืฆื ืืื ืื ื ืฆืจืื ืืฉืื ืข ืืช ืืืขืกืืง ืฉืื ื ืืืืจ ืืช ืืืืืจ ืืืกืืื ืืืฆืข ืืช ืืืืืืช ืืฆืืจื ืืืืื ืืืืชืจ.
ืืขืชืื ืืืชืจ ืงืจืืืืช ืื ื ืืืคืฉ ืขืืืื ืฉืชืงืื ืืืชื, ืขืืืื ืฉืื ื ืขืืืื ืื ืืืืข ืืื ืืืฆืข ืืื ืื ื ืืืฉื ืฉืืืื ืืืืื ืืฉื. ืืืฆื ืืื ืืืชืืจ ืืื ืืฉืื ืข ืืช ืืืขืกืืง ืฉืืฉ ืื ืืช ืืคืืื ืฆืืื ืืืฆืืื ืืขืฉืืช ืืช ืืืขืืจ (ืืืชืืช ืืื ืื, ื QA ืืืชืื ืช, ืืืชืื ืช ืืคืจืืืงื, ืื ืื ืืขืืจ ืืืจ ืฉืืชื ืืืืืื ืขืืื). ืื ืื ืืื ืงื ืืฉืื ืข ืืชืื ืืืจืืื ืืื ืืคืฉืจ ืื ืืฉืื ืข ืื ืฉืื ืืจืื. ืืื ืืืจืื ืฉืืืืชื ืื ืกื ืืืฆื ืืื-
1. ืืืืืื ืืงืืจืืช ืืืื ืืช ืืืืจืื ืืืืืื ืฉืขืฉืืชื ืืกืืืืก ืื ืืืื ืื ืืช ืืคืจืืืงืืื ืฉืืืฆืขืชื ืืืฆืืื.
2. ืืืชืืื ืืช ืืชืืืื, ืืื ืืืืืืจ ืขื ืืฆืืช ืชืืฆืจืื (ืื ืฉืืื 5 ืฉื ืื ืืชืื ืช ืืจืง ืืชืืื ืืคื ื ืืืืฉืืื ืงืืจืก UI/UX ืืืื ืื ืืฆืจ ืขืืืื ืืช ืืขืืฆืืืื ืืื ืืืืจืคืื).
3. ืืืืืื ืฉืื ืืืื ืืงืฆืืขืืื ืงืืืืื ืฉืขืฉืืชื, ืจืฆืื ืืืืชื ืืงืืื ืืืฆืืจืฃ ืืงืืจืืช ืืืืื.
4. ืืืืืช ืืืื ืื ืืชืงืืคืช ืืืฉืจื ืื ืืจืืื ืืฉืืจ. ืื ืืืื ืืืจืืฉืืช.
5. ืืืชืืื ืืงืื - ืชืื ืืื ืืืืคืืฉ ืฉืืื ืืืฆืื ืืงืืืืช ืืชืคืงืื ืื ืืืื ืื ืืคืืื ืืืชื ืืืืช ืืื ืืชื ืืืืืื ืืขืฉืืช ืืช ืืืืจ ืฉืืชื ืจืืฆืื ืืขืฉืืช. ืืืชื ืืชืื ืช ืืืื ืืื ืืช ืขืืฆืืื UI/UX ืืืคืืืงืฆืืืช ืืืืื ืืืช ืื ืืืชื ืืืืช. ืื ืืืื ืฉืืืืชื ืืฆืจืฃ ืืืชื ืืงืืจืืช ืืืื ืืื ืื ืฉืืืื ืืฉืื ืืืืจ ืขืืื ืืจืืืื.
ืืืืจ ืืืฉืื ืืฉืื ืืข ืืื ืืืจืืืช ืฉืืชื ืืืื ืื ืืช ืืืชืืจ ืืฉืืืื ืืืืจืื ืืืืชื ืฉืคื. ืืชืืจ ืืขืกืืง ืืืืชื ืืคืื ืืชืช ืฆ'ืื ืก ืืื ืฉืืชืืื ืืคื ื ืืืืฉืืื ืงืืจืก ืขืืฆืื ืืื ืืืจ ืืชื ืื ืืื ืืขืฆื-ืขื. ืืื ืื ืืื ืืื ืืืื ืฉืืื ืขืืืื ืจืืืง ืืืืขื ืืื ืืคืืงืก ืืืจื ืืฉื, ืืืจืื ืฉืืื ืขืฉื ืฉืื ืืืื ืืืืื ืืขืืจ ืืืืื ืืืชืืจ, ืืื ื ืืืื ืฆืจืื ืืขืฆื ืืืืจ ืืืืืฉ ืืืืฆืื ืืื ืขื ื ืืกืืื, ืืฉ ืกืืืื ืฉืืงื ืืช ืืกืืืื ืืืชื ืืช ืืืืืื ืืช.
1 420
playerRef.current = YouTubePlayer(playerDivRef.current);
playerRef.current.loadVideoById(videoId);
}
}, [])
const changeVideoId = (e) => {
const videoId = e.target.value;
setVideoId(videoId);
const player = playerRef.current;
if (player) {
player.loadVideoById(videoId);
}
}
return (
<div>
<div>
<button onClick={() => playerRef.current.playVideo()}>Play</button>
<button onClick={() => playerRef.current.pauseVideo()}>Pasue</button>
<div>
<input type="text" value={videoId} onChange={changeVideoId} />
</div>
<div ref={playerDivRef}></div>
</div>
</div>
)
}
function Toggle() {
const [hidden, setHidden] = useState(false);
return (
<div>
<input type="checkbox" checked={hidden} onChange={() => setHidden(v => !v)} /> Hide
{hidden ? <></> : <YoutubePlayerComponent />}
</div>
)
}
export default Toggle1 420
playerRef.current.loadVideoById(videoId);
}
}, [])
ืื ื ืื ืืืื ืืช ืื ืื ืืฉ ืคื ืืคืงื ืืื ืคืื ืงืฆืืืช ื ืืงืื ืืื ื ืจืื ืืื ืืฉืื ืฉืืืื ืืืืฉืืจ ืืงืจืื, ืืื ืืืืจ ื youtube-player ืืขืืื ืืช ื DOM ืืื ืืฉืืื ืืืชื ื ืืืช ืกืื ืฉื ืคืฉืจื ืฉืื ืืคืฉืจ ืืืชืืืง ืืื ื.
ืืื ืืฉืืืจ ืืืชื ืืืจื ืฉืฉืืืื ื
ืืกืืื ืืืจืืืืช ืฉืื ื ืื ืืืื ืืช ืืื ืื ืื ืืื ืืื ืื ืื ืกืชืจืช ืฉืืื ืืืื - ืืืขืงืฃ ืืืื ืื ืื ืกืืืื ืืคืื ืืืื ื ืื ืื ืืขืืื ืื ืืฉืชื ื ืืชืืฆืื ืืฉืื ืืืื ืืกืืืื. ืื ืืืจืื ืืฉืืื ืฉ youtube-player ืชืขืืื, ืฉืื ืืืื ืฉ youtube-player ืืฉื ื ืืช ื DOM.
ืื ืื ืื ื ืื ืกืื ืืขืืื ืืช ืืงืืืคืื ื ืื ืืื ืืฉื ืืช ืืช ื DOM ืืชืื ืจืืืงื ืืฉ ืืชื ืืฉืืช. ืฉืืื ืื ืืืืจืกื ืืฉืืืจื ืืืืช:
import { useEffect, useRef, useState } from 'react'
import YouTubePlayer from 'youtube-player'
const YoutubePlayerComponent = () => {
const [videoId, setVideoId] = useState('efGw88Wlncw');
const [hidden, setHidden] = useState(false);
const playerDivRef = useRef(null);
const playerRef = useRef(null);
useEffect(() => {
if (!playerRef.current) {
playerRef.current = YouTubePlayer(playerDivRef.current);
playerRef.current.loadVideoById(videoId);
}
}, [])
const changeVideoId = (e) => {
const videoId = e.target.value;
setVideoId(videoId);
const player = playerRef.current;
if (player) {
player.loadVideoById(videoId);
}
}
return (
<div>
<div>
<input type="checkbox" checked={hidden} onChange={() => setHidden(v => !v)} /> Hide
<button onClick={() => playerRef.current.playVideo()}>Play</button>
<button onClick={() => playerRef.current.pauseVideo()}>Pasue</button>
<div>
<input type="text" value={videoId} onChange={changeVideoId} />
</div>
{hidden ? <></> : <div ref={playerDivRef}></div>}
</div>
</div>
)
}
export default YoutubePlayerComponent
ืืืคืชืืจืื ืขืืืืื ืืื ืื ืื ื ืื ืกื ืืืืืฅ ืขื hide ืืื ื ืขืื ืืืืคืืขื ืืืืขืช ืฉืืืื ืืงืื ืกืื:
react-dom.development.js:12056 Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at removeChild (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:8467:26)
at commitDeletionEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17506:21)
at commitDeletionEffects (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17473:13)
at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17670:17)
at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17733:15)
at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17681:15)
at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17733:15)
at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17681:15)
at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17695:15)
at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/react-dom_client.js?v=782b4cde:17681:15)
ืจืืืงื ืื ืกื ืืืืืง ืืช ืื ืื ืืื ืืืื ืฉืื ืื ืืื ืฉืืืกืืฃ ืืช ืื ืื ืืืื ืืืืื ืืืืฉืืจ. ื ื, ืจืืื ื ืืช ืื ืื ืืฉ youtube-player ืืืืืื ืืฉื ืืช ืืช ื DOM ืื ืงืฉื ืืคืืื ืืืขืืก ืขืืื.
ืื ืืื ืืืช ืื ืื ื ืืชืขืงืฉืื ืืืืกืืฃ ืื ืื ืื ืฉื Toggle ื ืฆืืจื ืืื ืืช ืืืชื ืืชืื ืงืืืคืื ื ืื ืืืฆืื ืืช ืื ืื ืืืืืื, ืืืช ืื ืจืืืงื ืืืจ ืืกืืื ืืงืื:
import { useEffect, useRef, useState } from 'react'
import YouTubePlayer from 'youtube-player'
const YoutubePlayerComponent = () => {
const [videoId, setVideoId] = useState('efGw88Wlncw');
const playerDivRef = useRef(null);
const playerRef = useRef(null);
useEffect(() => {
if (!playerRef.current) {1 420
ืืืื ื ืฉืืืจ ืงืฆืช ืจืืืงื
ืืจืืืงื ืืฉ ืืื ืงืื ืกืคืืื ืคืฉืืืื ืฉืจืื ืืืื ืืฆืืืืื ืืืืืืง ืืขืจืืช ืืื ืืคืขืืื ืื ืืืืืื ืืืชื ื ืืงืฆืืืช ืฉื ืชืกืืื. ืื ืชืืื ืงืืจื ืื ืฉืืจื ื ืืืื ืืื ืจืืืงืื ืืื ืกืคืง, ืืื ืืืืื ืงืฉื ืืขืืื ืจืง ืืคื ืืืืืื. ืืืื ื ืืงื ืืืืืื ืืช ืืกืคืจืื youtube-player ื npm.
ืื ืฉืืืจ ืืกืคืจืื
ืืกืคืจืื youtube-player ื ืืชื ืช ืืืฉืง ืงื ืืขืืืื ืขื ื API ืฉื ืืืืืื. ืื ืื ื ื ืืชื ืื ืื ืืื ืื ืืืื ื DOM ืืืื ืืืฆืจืช ืืชืืื ื ืื ืืืืืื ืขื ืืืืคืจืืื ืืืื. ืืฉืืื ืืืฉืชืืฉ ืื (ืืชืื ืืชืืขืื ืฉืืื) ืฆืจืื ืจืง ืืืชืื:
let player;
player = YouTubePlayer('video-player');
// 'loadVideoById' is queued until the player is ready to receive API calls.
player.loadVideoById('M7lc1UVf-VE');
// 'playVideo' is queue until the player is ready to received API calls and after 'loadVideoById' has been called.
player.playVideo();
ืืกืืก ืืืจืืืื ื ืืื ืืื ืฉืจืืืงื ืืืื ืื ืืืื ืฉืืืฉืื ืืืจ ืืฉื ื ืื ืืช ื DOM, ืืขืื ืืขื ืืื ืืชืขืืจืจ ืืืชืจืื.
ื ืืกืืื ืจืืฉืื ืืฉืื ืืช ืืกืคืจืื ืขื ืจืืืงื ืืืื ืืืืจืืืช ืื-
import { useEffect, useRef, useState } from 'react'
import YouTubePlayer from 'youtube-player'
const YoutubePlayerComponent = () => {
const [videoId, setVideoId] = useState('efGw88Wlncw');
const playerDivRef = useRef(null);
const playerRef = useRef(null);
useEffect(() => {
playerRef.current = YouTubePlayer(playerDivRef.current);
playerRef.current.loadVideoById(videoId);
}, [])
const changeVideoId = (e) => {
const videoId = e.target.value;
setVideoId(videoId);
const player = playerRef.current;
if (player) {
player.loadVideoById(videoId);
}
}
return (
<div>
<div>
<button onClick={() => playerRef.current.playVideo()}>Play</button>
<button onClick={() => playerRef.current.pauseVideo()}>Pasue</button>
<div>
<input type="text" value={videoId} onChange={changeVideoId} />
</div>
<div ref={playerDivRef}></div>
</div>
</div>
)
}
export default YoutubePlayerComponent
ืืืฆืจืื ืงืืืคืื ื ืื, ืืขืืืื ืฉื ืืงืืืคืื ื ืื ืืืฆืจืื ืืช ืื ืื ืืื ืื ืคืขื ืฉืืฉืชื ื ืืืืื ืฉื ืืืืืื ืืืขื ืื ืืช ืืืืืื ืืืืฉ ืืจื ืื ืื. ืืคืฉืจ ืื ืืืืกืืฃ ืืคืชืืจืื ืฉื "ื ืื" ื"ืืคืกืง" ืืงืื ืืงืืืคืื ื ืื.
ืืงืื ื ืจืื ื ืืื ืืื ืืื ืื ืขืืื. ืืืคืชืืจืื ืื ืืชืคืงืืื.
ืงื ืืจืืืช ืฉืืืขืื ืืื ืืืคืงื ืฉืืืฆืจ ืืช ืื ืื. ืืืจื ืืื ืืคืงืืื ืฆืจืืืื ืืืืื ืงืื "ื ืืงืื", ืืืืืจ ืืืคืงื ืืื ืืืืืจ ืืืฉืื ืืืฆืื ื ื useEffect ืฆืจืืื ืืืืืืจ ืคืื ืงืฆืื ืฉืืืืืช ืืช ืืืืืืจ ืืื. ืืืงืจื ืฉืื ื ืืื ืืจื ืื ืงืืช ืืช ืืืืืืจ ืื ืืกืคืจืื youtube-player ืื ืืกืคืงืช ืืื. ืืื ืื ืืฆืืขื ืคืื ืงืฆืื ืืกืื ืืจืื ืืช ืืฉื destroy, ืืื ืืืกืื ืืจืื ืืืช ืฉื ืืคืื ืงืฆืื ืืื ืืขืืืชืืช. ืืคืื ืงืฆืื ืืกืืจื ืื DOM ืืช ืืืืื ื ืฉื ืื ืื ืืฆืืจื ืืกืื ืืจืื ืืช, ืืืื ืขืืืื ืืืกืืจ ืืืชื ืืจืื ืืืจื ืฉืืืคืงื ืืืื. ืืืืื ืืืจืืช ืื ืื ื ืื ืกื ืืืืกืืฃ ืืช ืงืื ืื ืืงืื ืืื:
useEffect(() => {
playerRef.current = YouTubePlayer(playerDivRef.current);
playerRef.current.loadVideoById(videoId);
return () => {
playerRef.current.destroy();
}
}, [])
ืืงืื ืืืฆืืจ ืืช ื iframe ืืฉืืื ืื ืื ืืื ืืื ืืืืง ืืืชื.
ืื ืฉืงืืจื ืืื ืื ืฉืืืฆื ืคืืชืื ืจืืืงื ืืคืขืื ืืช ืืืคืงื ืืื ืืจืืฅ ืืช ืงืื ืื ืืงืื ืฉืื ืืื ืืคืขืื ืืช ืืืคืงื ืฉืื. ืืืช ืืืืงื ืฉื ืจืืืงื ืฉื ืืขืื ืืืืื ืฉืืคืฉืจ ืืืื ืืืืืืืจ ืืช ืืืคืงื ืืื ืืขืื, ืืื ืืืงืจื ืฉืื ื ืื ืื ืขืืื ืื ืืืืืงื ืืื ืืกืื ืืจืื ืืช. ืคืื ืงืฆืืืช destroy ืชืืคืขื ืืืจื ืฉืจืืืงื ืืืื ืืช ืืืคืงื ืืืืืืจ ืืืชื ืืื ืชืืืง ืืช ืืืืืคืจืืื ืฉื ืื ืื ืืฉื ื. ืืืชื ืืชื ืืืืช ืืื ืื ืืืช ืฉืืจืื ืืืคืชืืจืื ืื ืืขืืื, ืืื ืืกืืื ืืืจืช. ืืฉืจืืืงื ืืืืข ืืืคืขืื ืืช ืืืคืงื ืคืขื ืฉื ืื ืืื ืืืฆืจ ื ืื ืืืฉ ืฉืืืจืก ืืช ืื ืื ืืงืืื. ืื ืื ืืจืืฉืื ืืื ืื ืฉืืชืคืงื ืืื ืืืคืชืืจืื ืืคืขืืืื ืืช ืืคืื ืงืฆืืืช play ื pause ืฉื ืื ืื ืืืืฉ ืฉืื ืืืืช ืืืืืจ ืืืืืคืจืืื.
ืืื ืืื ืืืช ืืฉืื ืืืชื ืืคืจืืืงื ืจืืืงื
ืืืฆืืื ืืืื ืื ืื ืื ื ืื ืจืืืงื ื ืฆืืจื ืืืชืคืฉืจ, ืืืฆืขืจื ืืขืืืื ืขื ืจืืืงื ืื ืื ืื ื ืฉืฆืจืืืื ืืืืชืจ. ืืคืืชืจืื ืืขืฆืื ืืื ืืืืืง ืืงืื ืืืคืงื ืื ืื ืื ืืืจ ืงืืื, ืืื ืื ืื ืืืฆืืจ ืืืฉ. ืื ื ืจืื ืื:
useEffect(() => {
if (!playerRef.current) {
playerRef.current = YouTubePlayer(playerDivRef.current);1 420
ืืื ืืืืืช ืชืืจืืฆืื ืืื ืืชืงืืืืช ืืงืฆืืขืืช
ืืฉ ืืืื ืกืืืืช ืืืืืช ืืืชืจืืง ืืืื ืืืืืื ืืืฉื ืืื ืืืฉื-
1. ืื ื ืืืจ ืืืฉ ืืื ื X, ืืฉืืื ืื ืืืืื ืืช ืืืื ืขื Y.
2. ืืื ืื ืฆืืจื ืืื ืืขืืืื ืฉืื.
3. ืื ืืื ืืืืค, ืชืืฃ ืืืชืืืืืช ืชืืืืจ ืืืืื ืืืืจื ืืืื ืืืืืื ืฉืืืชื ืงืืื.
4. ืืื ืืกืคืืง ืื ืฉืื ืืชืขืฉืืื ืฉืืฉืชืืฉืื ื Y ืืืื ืื ืืืืื ืืช ืืืื ืขื ืืฉืื ืฉืื ืืงืื ืืืชื.
5. ืืืืชื ืฉืื ืืืืื ืืช Y ืืื ืืจืืข ืื ืื ื ืืืืืง ืืืืฆืข ืคืจืืืงื, ืืืจื ืืืืจืกื ืืชืืื ืืืกืชืื ืขื ืื.
ืืืืื ืคืขืืื ืืกืืืืช ืืืื ืืืฉ ื ืืื ืืช. ืืฉ ืชืงืืคืืช ืืืืื ืฉืื ืฆืจืื ืืืืื ืฉืื ืืืจ ืืืฉ ืืืืืจ ืืืฉืื ืืื ืืืชืงืื ืืคืจืืืงื ืืืืืื ืฉืื ืื ื ืืื ืื. ืื ืื ืืืื ืืืื ื ืืืืืื ืืื ืืืืืืืช ืืืฉืืช ืื ืืื ืืื ืืขืืื.
ืืืขืื ืืื ืฉืืคืขืืื ืื ืฉื ืฉืืข ืืื ืกืืื ืืืฉ ืืืื ืืื ืืขืฆื ืชืืจืืฅ ืฉืืจืืืฉ ืืื ืกืืื. ืชืืจืืฅ ืฉืืชืืื ืื ืื ืืื ืฉืืคืืื ืืื ืืื ืฉื ืืชื ืืืชื ืื ืืฆืืื ืืฉืื ืื ืฉืืฉ ืคื ืืฉืื ืืฉืื.
ืืจืืง ืืื ืฉืขืืื ืืฉืืืื ืืื ืืืืืช ืืชื ืื ื ืืืืช ืขืกืืง ืืื ืืืชื ืื ื ืจืง ืืชืืืง ืืื ืืืืจืื ืืช ืืืื ืืืื ืขืืื ืื ื ืืกืชืื. ืืืงืื ืืืกืชืื ืขื ืืืืจ ืฉืื ื ืฆืจืื ืืืืื ืขืืฉืื ืื ื ืืกืชืื ืืืืจื ืืืฉืื-
1. ืืื ืืื ืืืืืืืช ืืืฉืืช ืืืืชื ืืฉื ื ืืืืจืื ื?
2. ืืื ืืืื ืืืฉืื ืฉืืืืชื ืืขืืืื ืฉืื ืืฉื ื ืืืืจืื ื ืืฆืืจื ืฉืชืจืื ืืคืจืืืืงืืืืืืช?
3. ืืื ืืฉ ืื ืจืฉืืืช ืืื ืืืืืืืช ืืืืืื ืืขืืื ืืชืืื ืฉืื ืฉืื ื ืืืืข ืฉืื ื ืฆืจืื ืืืงืืจ? ืืื ืื ืืื ืืฆืืืชื ืืงืฆืจ ืืืชื ืืฉื ื ืืืืจืื ื?
ืืฉืืกืชืืืื ืขื ืฉื ื ืืืืจื ืืืงืื ืขื ืืืจ ืืืืงืจ ืืืชืจ ืงื ืืืืื ืืช ืืกืืืืืฆืื. ืืื ืืืฆืืงืืช ืฉืื ืืืื ืืกืืืืช ืฉืืฉ ืื ืืืื ืื ืืื ืื ืืื ืฉื ืืคื ื ืืืืฉ, ืืืืฉืืื ืื ืืฆื ืฉื ื. ืืืชืจ ืืื, ืจืง ืืฉืื ืื ืฉืืฉื ื ืืืืจืื ื ืื ืืงืืช ืืฃ ืฆืขื ืงืืืื ืื ืืืืื ืืืืืืช ืฉืืืืื ืืฉื ืืช ืกืืจื ืขืืืคืืืืช. ืืฉ ืืืื ืฉืื ื ืืืืืช ืืืคืืื ืืืขืืืจ ืฉื ืื ืขื ืืืืก ืืืืืืื. ืืืืื ืืื ืื ืื ืืื ืืืื ืืื ืืืืืื ืืช ืฉืื ื ืืืืื ืฉืืืื ืืืชืจ.
1 420
ืืฉืืงืื ืขื ืืงืืืืืืช ืืกืงืืื (ืืืง 2)
ืืืืง ืืงืืื ืฉื ืืคืืกื ืืชืืชื ืขื pmap ืืืื ืืคืฉืจ ืืืฉืชืืฉ ืื ืืื ืืืืง ืคืขืืื ืืืฉืืืืช ืืืกืคืจ ืชืืืืืื ืื ืืื ืืฉืคืจ ืืืฆืืขืื. ืืืื ืื ื ืจืืฆื ืืืืจ ืขื ืขืืืืช IO, ืขื ืืืืืื ืฉื Thread Pool ืืืืงืืื ืืฉืืืืช ืืงืฉืืจืืช ื IO ืืขื ืืคืืชืจืื ืขื Virtual Threads.
ืื ืืขืฆื ืืืขืื
ื ืชืืื ืขื ืืงืื ืืื ืืกืงืืื ืฉืืฉืชืืฉ ื Thread Pool ืืื ืืืืจืื ืืืงืืื ืืืืข ื 50 ืขืืืืื ืืืชืจ ืืกืืื (ืื ืื ืชืื ืื ืืืชืจ ืืืืืคืื ืืื ืื ืื ืืฉื ื):
object futures {
given ExecutionContext = ExecutionContext.global
private def printUrlContent(url: String): Unit =
Using(Source.fromURL(url)) { reader =>
reader.getLines().mkString("\n")
}
println(s"Done: ${url}")
@main
def test(): Unit =
val s1 = System.nanoTime()
1.to(50)
.map {i => s"https://dummyjson.com/products/${i}" }
.map { url => Future { printUrlContent(url)} }
.foreach { f => Await.result(f, Duration.Inf) }
val s2 = System.nanoTime()
println(s"Took ${s2 - s1} ns")
}
ืื ืืืืื ืื ืื ื ืืืฉืืื 50 ืืชืืืืช ืืื ืืจื ื ืืืชืจ dummyjson.com, ืฉืืืืื ืืงืฉืช HTTP ืืื ืืชืืืช ืืืืืงืื ืืื ืืื ืืงื ืืืฉืื ืืช ืื ืืืืืข.
ืืจืฆื ืฉื ืืชืืื ืืช ืืฆืืื ืชืืฆืื ืืขื ืืื ืช - ืื ืื ื ืจืืืื ืืช ืืคืื ื ืืชื ืืืกื ืืงืืืฆืืช ืฉื URL-ืื, ืืืืืจ ืืืืื ืงืฆืช ืืื, ืจืืืื ืืืคืกื ืฉื ืืกืคืจ ืฉืืจืืช ืืื ืืืืื ืขืื ืงืฆืช ืืขืื ืืืคืกื. ืื ืงืืจื ืืืื ืืืื ื ืฉื Thread Pool ืืืฉืืืื ืขื ืขืืืืช IO. ืืกืื ืขืืืื ืืื ืื ืฉืืืกื ืืืชื ื ืืื ืืจืฉืช ืืื ืืืืฉื ืฉืื ื, ืืืื ืื ืืชืืืืืื ืื ืขืืืืื ืขื ื ืืืืจื ืืืขืฆื ืืืืื ืืืืืข. ืืืขืื ืฉื Thread Pool ืืืื ืืืจืืฅ ืจืง ืืกืคืจ ืืืืื ืฉื ืชืืืืืื ืื ืืืื ืฆืจืื ืืืืืช ืขื ืฉืชืืืืืื ืืกืืื ืืืชืคื ื ืืคื ื ืฉืืชืืืืื ืืืืจืื ืืช ืื ืชืื ืืื.
ืืขืืจ ื Virtual Threads
ืืืื ืื ืื ื ืืืืื ืืช ืืคืืื ืฆืืื ืฉื Virtual Threads. ืืืจื ืืื ืื Thread ืชืืคืก ืืฉืืืื ืืืื ืื ืืืืืฅ ืืืฆืืจ ืืืชืจ ืืื ืืื, ืืฉืื ืืกืืื ืื ืืฆืจื ืขืืืก ืขื ืืขืจืืช ืืืคืขืื ืืจืง ืืืื ืืช ืืชืืื ืืช. ืชืืืืืื ืืืจืืืืื ืืื ืื ืื ืื ืฉื ื JVM ืฉืื ืืืฆืจ Thread ืืืขืจืืช ืืืคืขืื (ืื ื ืงืจื fiber ืืืจืื ืืงืืืืช ืืืจืื) ืืืื ืืคืฉืจ ืืืฆืืจ ืืืื ืืื ื. ื ืืื ืื ืืคืขืืื ืฉืื ืื ื ืื ืกืื ืืขืฉืืช ืืื ืืฉืืื ืืืฉืืืืช ืืืืกืืฃ ืขืื ืชืืืืืื ืื ืื ืชืืืืืื ืื ืืืจืืืืืืื ืื ืืฉืคืจ ืืช ืืฆืื ื, ืื ืขืืืื ืืืื ืขืืืก ืขื ืืืขืื, ืืื ืืฉืืืืืจ ืืคืขืืืืช IO ืืืืื ืืืขืื ืื ืขืืฉื ืืืื ืืืืืืืืช ืืืืขื ืืืจืฉืช ืืื ืืืืืฉื ืฉืื ื - ืืืื ืชืืืืืื ืื ืืืจืืืืืืื ืืืืืื ืืฉื ืืช ืืช ืืชืืื ื.
ืืกืงืืื (ืืื ื Java) ืืฉ ืงืืืก ืืฉื ExecutorService ืฉืืืจืื ืขื ืืฆืืจืช ืืชืืืืืื ืื ืืืื ืื ืื ืฉืฆืจืื ืืฉืืื ืืืชืืื ืืขืืื ืขื ืชืืืืืื ืื ืืืจืืืืืืื ืืื ืืฉื ืืช ืืช ื ExecutorService ืฉืื ื. ืขืืืื ืืชืืื ืืช ืืขืืืื ืขื ืชืืืืืื ืื ืืืจืืืืืืื ืืื ืืกื ืืื ืฉืื ืื ืฉื ืืฉืืจื ืืจืืฉืื ื ื:
given ExecutionContext = ExecutionContext.fromExecutorService(Executors.newVirtualThreadPerTaskExecutor())
ืืืชืืื ืืช ืืืืื:
object futures {
given ExecutionContext = ExecutionContext.fromExecutorService(Executors.newVirtualThreadPerTaskExecutor())
// given ExecutionContext = ExecutionContext.global
private def printUrlContent(url: String): Unit =
Using(Source.fromURL(url)) { reader =>
reader.getLines().mkString("\n")
}
println(s"Done: ${url}")
@main
def test(): Unit =
val s1 = System.nanoTime()
1.to(50)
.map {i => s"https://dummyjson.com/products/${i}" }
.map { url => Future { printUrlContent(url)} }
.foreach { f => Await.result(f, Duration.Inf) }
val s2 = System.nanoTime()
println(s"Took ${s2 - s1} ns")
}
ืืืจืกื ืื ืฉื ืืชืืื ืืช ืจืฆื ืืืืฆืืช ืืืื, ืืื ืฉืืืชืจ ืืขื ืืื ืืื ืฉืืื ืื ืืช ืืืืืงื ืืงืืืฆืืช ืฉืืคืืื ื ืืช ืืขืืืื ืขื Thread Pool. ืื ืืืืืขืืช ื ืืชืืืช ืืืกื ืืื, ืืืื ืฉืืจืืฉ ืืฆืจื ื Thread ืืืจืืืืื ืืื ืืฉืืื.1 420
ืืื ืืื map ืืฉืืื ืืฉื ืืช ืขืจืืื ืืืืงืื ืืกืืื ื JavaScript
ืื ืื ืคืขื ืฉืืจืชื ืืขืจื ืืกืืืื ืฉื ืงืืืคืื ื ืืช ืจืืืงื ืืชื ืืืืื ืืืืจืื ืืช ืืจืืข ืฉื ืืกืืชื ืืฉื ืืช ืจืง ืขืจื ืืื ืืืขืจื ืืืืขืืืจ ืืช ืืชืืฆืื ื set, ืจืง ืืฉืืื ืืืืืช ืฉ setState ืื ืขืืฉื ืืืื ืื ืืืขืจื ืขืฆืื ืื ืืฉืชื ื. ืืืจื ืื ืืืืชื ืืืฉืชืืฉ ื map ืืื ืืืฆืืจ ืืขืจื ืืืฉ ืขื ืฉืื ืื ืืืื ื ืืืื ืืงืก ืืกืืื-
const newItems = oldItems.map((item, index) =>
index === 1 ? 99 : item);
ืืื ืืืืขื immer ืืฉืื ืืฆืืื ื ืืืชืื ืงืื ืจืืื ืืื ืืืขื ื ืืื ืฉืื ืื ืืืืืง ืื ืืฉืื ืื ืื ืืคืจืืงืกืื ืฉื immer ืขืืื ืืืื ื ืืจืื ืืืงืจืื ืืื ืืกืืฃ ืชืืื ืืืื ืืืื ืืื (ืื ืืืื immer ืืจืืจ, ืืชื ืคืฉืื ืืืืืงืื ืืช ืื ืื ื ืืื).
ืืงืืฆืืจ ืงืืืืจืื ืืฆื ืืืืจืื ื JavaScript ืงืืืื ืืื ืืืคืืคื ืื ืชืืืื ืืคืืชืจืื ืืืื ื ืืฉืื ืื ืืขืจืืื ืืคื ืืื ืืงืก ืืืื map. ืื ื ืจืื ืืื-
const newItems = oldItems.with(1, 99);
ื ืฉืื ืื ืฉืื ืืคืฉืจ ืืืชืื ืืืจื ืกืืฃ ืืืขืจื ืื ืฉืื ื ืืฉื:
[].with(99, 0)
ืื ืืกืฃ with ืฉืืืจ ืืขืจืืื ืืจืืืืื, ืืื ืื ื ืื ืืืื ืืื ื ืืง ืื ืขืืื ืืืจืื. ืืืืืจ ืืงืื ืืื:
Array(10).forEach(() => console.log('1'))
ืืืงืื ืืื:
Array(10).with(0, 0).forEach(() => console.log('1'))
ืืขืฉื ืืืจืื ืฉืื ืื - ืืจืืฉืื ืื ืืืคืืก ืืืื, ืืฉื ื ืืืคืืก 10 ืคืขืืื ืืช ืืืืืขื. ืืื ืชืืืื ืืืกืคืจ ืืื ืืงืกืื ืืืชืืื ืืชืื ืืขืจืืื ืืงืื ื ืื, ืืื ืื ืืฉ ืชืืืื ืืืื ืืงืกืื ืฉืืืืืื ืืืชืืื ืืกืืฃ ืืืขืจื:
[1, 2, 3, 4, 5].with(-1, 10)1 420
ืืืื ืืืืชื - ืืืคืืก ืืืืจืืช postcss ืืคืจืืืงื vite
ืืคืขืืื ืงืฉื ืืืืื ืืื ืคืจืืืงืื Front End ืื ืืฆืืืืื ืืขืืื ืืื ืืื, ืื ืฉืืืื ืืืขืื ืืื ืืฆืื ื ืืืชืื ืชืื ืฉืคืฉืื ืืืืคืื ืขืื ืืขืื ืฉืืืืืช ืืคืจืืืงื ืืืกืืฃ ืืชืคืืืื ืืฉืืืคืืขืืช ืืืืขืืช ืฉืืืื ืืืืจืืช.
ืืกืืคืืจ ืฉืืืื ืืงื ืื ืืืชืจ ืืื ืฉืขืืช ืืืืืื ืงืฉืืจ ื postcss ืืืืชื ืืืืช ืืืืืจื ืฉืื ืืชืื ืคืจืืืงื vite - ืืืขืืจ ืืืืจื ืืืจืช, postcss ืืืคืฉ ืงืืืฅ ืืืืจืืช ืืืขืื ืขืฅ ืืชืืงืืืช ืขื ืืชืืงืืืช ืืืืช. ืืฉืืื ืื ืืกืื ืฉืืชื ืืชืืงืืืช ืืืืช ืงืืืฅ ืืฉื postcss.config.js ืขื ืืชืืื ืืื:
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
ืืื ืืฆืจืชื ืคืจืืืงื vite ืืืฉ ืืืืจื ืืชืืงืืื:
/Users/ynonp/a/b/c/d/helloworld
ืืคืขืืชื npm run build ืืชืืงืื ืืงืืืืชื ืืช ืืืืขืช ืืฉืืืื ืืืื:
> helloworld@0.0.0 build
> tsc && vite build
vite v5.1.3 building for production...
transforming (1) index.htmlnode:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
[Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /Users/ynonp/a/b/c/d/helloworld): [Error] Loading PostCSS Plugin failed: Cannot find module 'tailwindcss'
Require stack:
- /Users/ynonp/postcss.config.js
(@/Users/ynonp/postcss.config.js)
Error: Loading PostCSS Plugin failed: Cannot find module 'tailwindcss'
Require stack:
- /Users/ynonp/postcss.config.js
(@/Users/ynonp/postcss.config.js)
at load (file:///Users/ynonp/a/b/c/d/helloworld/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:28883:11)
at file:///Users/ynonp/a/b/c/d/helloworld/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:28908:16
at Array.map (<anonymous>)
at plugins (file:///Users/ynonp/a/b/c/d/helloworld/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:28907:8)
at processResult (file:///Users/ynonp/a/b/c/d/helloworld/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:28977:14)
at file:///Users/ynonp/a/b/c/d/helloworld/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:29107:14]
Node.js v21.5.0
ืืื ืื ืืงื ืืจืื ืืืชืจ ืืื ืืืืืช ืฉืืกืืื ืืืืืขื ืืื ืืขืฆื ืืงืืืฅ postcss.config.js ืฉื ืืฆื ืืชืืงืืืช ืืืืช ืฉืื.
ืคืืชืจืื? ืื ืคืฉืื ืืกืชืืจ ืืืจื ืฉืืืื ืื ืืช ืืืขืื. ืืืฆืจืื ืงืืืฅ vite.config.js ืืชืืงืืืช ืืคืจืืืงื ืขื ืืชืืื ืืื ืืืื ืืกืชืืจ:
import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig({
css: {
postcss: {},
},
})
ืื ื ืืื ืื ื ืื ืืงืื ืืช ืืืฆื ืืื ืฉืื ืืืืจื, ืืื ืืืื ืืคืืกื ืืื ืืืกืื ืืื ืืื ืฉืขืืช.1 420
ืขืื ืืืฉืื ืขื ืชืื ืืช ื index.ts ืฉืืืืฆื ืืื
ืืืื ื ืืืืื ืคืจืืืงื ืจืืืงื ืฉืืฉ ืื ืชืืงืืื ืืฉื
src/components/HomePage ืืืชืืื ืขืจืืื ืฉื ืชืืงืืืช ืืงืืืฅ ืืื ืืฉื index.ts:
.
โโโ EmptyState
โ โโโ EmptyState.tsx
โ โโโ index.ts
โโโ ErrorState
โ โโโ ErrorState.tsx
โ โโโ ErrorState.types.ts
โ โโโ index.ts
โโโ RecentArticles
โ โโโ RecentArticles.tsx
โ โโโ RecentArticles.types.ts
โ โโโ index.ts
โโโ RecentArticlesCard
โ โโโ RecentArticleCard.tsx
โ โโโ RecentArticleCard.types.ts
โ โโโ index.ts
โโโ RecentArticlesContent
โ โโโ RecentArticlesContent.tsx
โ โโโ RecentArticlesContent.types.ts
โ โโโ index.ts
โโโ index.ts
ืชืืื ืืงืืืฅ index.ts ืืืื:
export * from './EmptyState';
export * from './ErrorState';
export * from './RecentArticles';
export * from './RecentArticlesCard';
export * from './RecentArticlesContent';
ืืื ืฉืืืฉืื ืืืชืื ืืื? ืื ืืืชืจืื ืืช ืืื ืืืกืจืื ืืช? ืืืื ืืืื ืื ื ืื ืืืฉืชืืฉ ืืชืื ืืช ืื ืืคืจืืืงืืื ืฉืื ื? (ืื ืื ื ืืืืข ืจืืืื ืืืจ ืืฉืชืืฉืื. ืืืื ืื ืืคืืกื)
ืืื ืื ืืืชืื ืืื
ืืฉืืืืฉ ืืงืืืฅ ืืื ืืงืก ืจืืฉื ืืชืืงืื ื ืืขื ืืืงื ืขื ืื ืฉืื ืฉืขืืฉืื import ืืงืืฆืื ืืืืชื ืชืืงืืื. ืงืืืฅ ืืืจ ืืืืชื ืืคืจืืืงื ืฉืืืืื ืงืืฆืื ืืืื ืืืชืื:
import { EmptyState, ErrorState, RecentArticles } from '@/components';
ืืื ื ืืื ืื ืขืืฉืื ืื ืฆืจืื ืืืฉืื ืืืืื ืชืืงืืื ืืืืขื ืื ืงืืืคืื ื ืื.
ืืืชืจ ืืื, ืื ืืคืจืืืงื ืฉืื ืืื ืกืคืจืื ืฉืื ืฉืื ืืืจืื ืขืืฉืื import ืืืืจืื ืืชืืื, ืื ืืืืชื ืืืื ืืืขืืืช ืืืจืกื ืืืฉื ืืช ืืืงืืืื ืฉื ืงืืฆืื ืืฉืืืช ืฉืืื ืืื ืฉืืืชื ืื ืฉืื ืฉืืฉืชืืฉืื ืืกืคืจืื ืฉืื ืืฆืืจืื ืืขืืื ืืช ืืงืื ืฉืืื. ืื ืืืจ ื ืืฆืืื ืจืฆืื ื.
ืืื ืื ืืืชืื ืืื
ืืืืจื ืืฉืืจืช ื import ืฉืืฆืืชื ืืงืืข ืืงืืื-
import { EmptyState, ErrorState, RecentArticles } from '@/components';
ืื ืฉืงืืจื ืืช ืื ืฆืจืื ืืืืืจ ืืขืืืง ืืช ืืื ื ืืชืืงืืืช ืืคืจืืืงื (ืืืืืืจ ืืช ืืืื ื ืืขื ืคื), ืื ืืกืืื ืขื IDE ืฉืืืข ืืงืจืื ืืืคื ืื ืืืจ. ืืคืขืืื ืืฉ ืื ื ืืืฉื ืืืื IDE ืืื ืืคืขืืื ืื ืื ื ืฆืจืืืื ืืงืจืื ืงืื ืืกืืืื ืคืืืช ืืืืืืชืืช ืืื ืืืชืจ ืงืฉื ืืืฆืื ืืช ืืงืืืคืื ื ืืืช.
ืืืชืจ ืืจืืข, ืงืืฆื index.ts ืืืจืฉืื ืชืืืืงื - ืื ืคืขื ืฉืื ื ืืฉื ื ืฉื ืฉื ืืฉืื ืืคืจืืืงื ืื ืืืื ืงืืืฅ ืืืงืื ืืืงืื ืื ื ืฆืจืื ืืชืงื ืืช ืืืคื ืืืช ืืงืืืฅ ืืืื ืืงืก ืืืชืืื. ืื ืืคืจืืืงื ืืื ืกืคืจืื ืขื ืืฉืชืืฉืื ืืืฆืื ืืื ืื ืืืืจื ืฉืืื ืืช ืืืฉืงืขื, ืืื ืื ืืืฉืชืืฉ ืืืืื ืืงืืืคืื ื ืืืช ืืื ืงืื ืืคืจืืืงื ืขืฆืื ืื ืื ืืจืืืื ื ืืืื.1 420
8. ืืขืืฉืื ืื ืฉืื ืื ืฉืชืขืฉื ืืขื ืฃ gh-pages ืืชืืืคื ืืืืืืื ืืืจืื ืืื ืืื ืืืืฉ ืฉื ืืฃ ืืคืจืืืงื.
1 420
ืืื ืืืฆืืจ ืืฃ Github Pages ืืคืจืืืงื ืฉืื
ืืื ืื ืืชื ืืื ืื ืคืจืืืงื ืืฉืืื ืืขืืื ืื ืจืง ืืฉืืื ืงืืจืืช ืืืืื, ืืฃ ืืื ืืคืจืืืงื ืืื ืฉืืกืืืจ ืื ืืื ืขืืฉื ืืืื ืืขืืืจ ืืื ืฉืื ืืืฆืื ืืชืื, ืื ืืืืกืื ืคืืื ืฆืืืืืื ืืืชืจืฉื ืืืขืืืื ืฉืืื. ืืื ืืืจ ืืคืจืืืงื ืฉืืืจ ืขื ืืืืืื ืืืื ื ืื ื ืื ืื ืืฃ ืืืืข ืฉืืืืืกื ืืืืชื ืืงืื, ืืชืฉืชืืช ืฉื Github Pages.
ืืื ืืืฆืืจ ืืฃ Github Pages ืืคืจืืืงื
ืืืจื ืฉืืขืืืชื ืืช ืืคืจืืืงื ืืืืืืื ืืืืข ืืืื ืืืฆืืจ ืขืืืจื ืืฃ ืืืืข. ืืืฃ ืืื ืคืจืืืงื Front End ืจืืื ืฉื ืฉืืจ ืืชืืงืืื ื ืคืจืืช ืืคืจืืืงื, ืืืืืื ืฉืื ืื ื ืงืืจื ืืชืืงืื gh-pages. ืื ื ืื ืื ืืช ืืงืืฆืื ืืืฃ ืืืืืข ืืขื ืฃ ื ืคืจื, ืฉืื ืื ืื ื ืงืืจื ืืฉืืื ืื ืืืืช gh-pages. ืื ืคืขื ืฉื ืขืื ืฉืื ืื ืืืืชื ืขื ืฃ ืืืืคื ืืืืืืื ืืืืืื ืืื ื ืืช ืืฃ ืืืืืข ืืืขืืื ืืืชื ืืจืฉืช. ืืืชืืืช ืฉื ืืฃ ืืืืืข ืชืืื:
https://<user>.github.io/<repo>
ืืืฉืจ user ืืื ืฉื ืืืฉืชืืฉ ืืืืืืื ืฉืืื ื repo ืืื ืฉื ืืืืืจ ืฉื ืืคืจืืืงื. ืืืื ืื? ืืืื ื ืืื ืก ืืชืืงืืืช ืืคืจืืืงื ืื ืฆื ืืืจื-
1. ืฆืจื ืืช ืืขื ืฃ gh-pages ืื ืืืฉืืจ ืืืฃ:
$ git switch -c gh-pages
2. ืืืืชื ืขื ืฃ ืฆืจื ืชืืงืื ืืืฉื ืขืืืจ ืืงืืฆืื ืฉื ืืืฃ. ืืคืฉืจ ืืืฆืืจ ืืช ืืคืจืืืงื ืขื vite.
$ npm create vite@latest gh-pages
3. ืขืจืื ืืช ืืงืืฆืื ืฉืืชืืงืืื ืืื ืืืฆืืจ ืคืจืืืงื ืฆื-ืืงืื (ืื ื ืืืจืชื ืจืืืงื ืืืืืคืกืงืจืืคื, ืืื ืืคืฉืจ ืืืืืจ ืื ืืื ืืืืืืืช ืฆื ืืงืื ืฉืชืจืฆื). ืื ืฉืืฉืื ืฉืืคืจืืืงื ืืืื ืืืืื ืืช ืขื npm build ืืื ืฉืืืืืช.
4. ืืขืืื ืืช ืืขืืืื ืฉืื ื ืืขื ืฃ ืืืืฉ ืืืืืจ:
$ git add .
$ git commit -m 'created gh page'
$ git push --set-upstream origin gh-pages
5. ืชืงื ื ืืช ืืืืืจืืช - ืืงืืืฅ vite.config.js ืื vite.config.ts ืืฉ ืืขืืื ืืช ืืคืชื ื base ืืื ืฉืืชืืื ืืืืืืื ืืืื ืืชื ืืืืืื ืืืขืืืช ืืช ืืคืจืืืงื. ืื ืื ื ืืืฆืจืื ืืฃ ืืืืืื ืืคืจืืืงื ืงืืื ืืืืงืจื ืฉืื ืฉื ืืืืืจ ืืื blog-to-telegram ืืื ืื ื ืืฉืชืืฉ ืืฉื ืืคืจืืืงื ืืชืืจ base. ืืงืืืฅ ืืืจื ืืฉืื ืื ื ืจืื ืื:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
base: '/blog-to-telegram/',
plugins: [react()],
})
6. ืฆืจื ืชืืงืื ืืืฉื ืืคืจืืืงื (ืชืืช ืืชืืงืื ืืจืืฉืืช) ืืฉื .github/workflows ืืืชืืื ืฆืจื ืงืืืฅ ืืืืื ืฉื ืฉืชืืืจื ืขื ืกืืืืช yml, ืืืฉื ืืงืืืฅ ืฉืื ืงืจืืชื deploy-gh-page.yml. ืชืืื ืืงืืืฅ ืืื:
* Simple workflow for deploying static content to GitHub Pages *
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ['gh-pages']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
* Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages *
permissions:
contents: read
pages: write
id-token: write
* Allow one concurrent deployment *
concurrency:
group: 'pages'
cancel-in-progress: true
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install dependencies
working-directory: ./gh-pages
run: npm install
- name: Build
working-directory: ./gh-pages
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload dist repository
path: './gh-pages/dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
7. ืืืคื ืืช ืื ืืฉืื ืืืื ืืคืจืืืงื:
$ git add .
$ git commit -m 'add workflow'
$ git push
ืืขืช ืืื ืกื ืืืฃ ืืคืจืืืงื ืฉืืื ืืืืืืื ืืืืจื ืืืื Actions. ืืืฆื ืขื ืืืงืฉื ืืืืฉ ืฉืืฆืจืชื ืืื ืืื ืขืื ืืื ืฉืฆืจืื ืืชื ืชืจืื ืืืื ืกืืื ืฉื ืื ืืจืืง ืฉืืกืื ืฉืืื ืืืฆืขื ืืืฆืืื. ืืืฆื ืขื ืืื ืืืจืืง ืืชืืืขื ืืืกื ืืืจืฆื ืืื ืืฉ ืชืืื ืืฉื deploy ืขื ืื ืชืื ืืื ื ืฉืืจ ืืืฃ ืฉืืื. ืืืฆื ืขื ืืืื ืง ืืื ืืจืืืช ืืช ืืขืืื ืืืืืืจ.
Endi mavjud! Telegram Tadqiqoti 2025 โ yilning asosiy insaytlari 
