Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eedb9a24f3 | |||
| 998c3d490d | |||
| bb3f733ffc | |||
| ce7b5dab6b | |||
| 13d52ec590 | |||
| 71ce77980d |
14
.drone.yml
14
.drone.yml
@@ -63,6 +63,9 @@ steps:
|
|||||||
|
|
||||||
- name: build-image
|
- name: build-image
|
||||||
image: docker:24
|
image: docker:24
|
||||||
|
environment:
|
||||||
|
API_BASE_URL:
|
||||||
|
from_secret: API_BASE_URL
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
@@ -70,7 +73,12 @@ steps:
|
|||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
||||||
|
|
||||||
- echo "🔨 Building Docker image apps/blog:$IMAGE_TAG ..."
|
- echo "🔨 Building Docker image apps/blog:$IMAGE_TAG ..."
|
||||||
- docker build --network=host -t apps/blog:$IMAGE_TAG -t apps/blog:latest /drone/src
|
- |
|
||||||
|
docker build --network=host \
|
||||||
|
--build-arg VITE_API_BASE_URL="$API_BASE_URL" \
|
||||||
|
-t apps/blog:$IMAGE_TAG \
|
||||||
|
-t apps/blog:latest \
|
||||||
|
/drone/src
|
||||||
|
|
||||||
- name: push-image
|
- name: push-image
|
||||||
image: docker:24
|
image: docker:24
|
||||||
@@ -108,9 +116,6 @@ steps:
|
|||||||
|
|
||||||
- name: run-container
|
- name: run-container
|
||||||
image: docker:24
|
image: docker:24
|
||||||
environment:
|
|
||||||
API_BASE_URL:
|
|
||||||
from_secret: API_BASE_URL
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: dockersock
|
- name: dockersock
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
@@ -123,7 +128,6 @@ steps:
|
|||||||
--name blog \
|
--name blog \
|
||||||
-p 3002:3000 \
|
-p 3002:3000 \
|
||||||
-e NODE_ENV=production \
|
-e NODE_ENV=production \
|
||||||
-e VITE_API_BASE_URL=$API_BASE_URL \
|
|
||||||
--restart always \
|
--restart always \
|
||||||
apps/blog:$IMAGE_TAG
|
apps/blog:$IMAGE_TAG
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ RUN npm ci
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the app
|
# Build the app
|
||||||
RUN npm run build
|
ARG VITE_API_BASE_URL
|
||||||
|
RUN VITE_API_BASE_URL=$VITE_API_BASE_URL npm run build
|
||||||
|
|
||||||
# Stage 2: Static file server (BusyBox)
|
# Stage 2: Static file server (BusyBox)
|
||||||
FROM busybox:latest
|
FROM busybox:latest
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aetoskia-blog-app",
|
"name": "aetoskia-blog-app",
|
||||||
"version": "0.0.4",
|
"version": "0.0.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -59,7 +59,17 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
|||||||
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }}
|
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }}
|
||||||
>
|
>
|
||||||
{selectedArticle === null ? (
|
{selectedArticle === null ? (
|
||||||
|
<>
|
||||||
<MainContent articles={articles} onSelectArticle={handleSelectArticle} />
|
<MainContent articles={articles} onSelectArticle={handleSelectArticle} />
|
||||||
|
<Latest
|
||||||
|
articles={articles}
|
||||||
|
onSelectArticle={handleSelectArticle}
|
||||||
|
onLoadMore={async (offset, limit) => {
|
||||||
|
// Optional: fetch more from API (if you want true pagination)
|
||||||
|
// await fetchMoreArticles(offset, limit);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Article article={articles[selectedArticle]} onBack={handleBack} />
|
<Article article={articles[selectedArticle]} onBack={handleBack} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,92 +3,12 @@ import Avatar from '@mui/material/Avatar';
|
|||||||
import AvatarGroup from '@mui/material/AvatarGroup';
|
import AvatarGroup from '@mui/material/AvatarGroup';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Grid from '@mui/material/Grid';
|
import Grid from '@mui/material/Grid';
|
||||||
import Pagination from '@mui/material/Pagination';
|
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import { styled } from '@mui/material/styles';
|
import { styled } from '@mui/material/styles';
|
||||||
import NavigateNextRoundedIcon from '@mui/icons-material/NavigateNextRounded';
|
import NavigateNextRoundedIcon from '@mui/icons-material/NavigateNextRounded';
|
||||||
|
import CircularProgress from '@mui/material/CircularProgress';
|
||||||
|
import type { Article } from '../providers/Article'; // ✅ import type for correctness
|
||||||
|
|
||||||
const articleInfo = [
|
|
||||||
{
|
|
||||||
tag: 'Engineering',
|
|
||||||
title: 'The future of AI in software engineering',
|
|
||||||
description:
|
|
||||||
'Artificial intelligence is revolutionizing software engineering. Explore how AI-driven tools are enhancing development processes and improving software quality.',
|
|
||||||
authors: [
|
|
||||||
{ name: 'Remy Sharp', avatar: '/static/images/avatar/1.jpg' },
|
|
||||||
{ name: 'Travis Howard', avatar: '/static/images/avatar/2.jpg' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Product',
|
|
||||||
title: 'Driving growth with user-centric product design',
|
|
||||||
description:
|
|
||||||
'Our user-centric product design approach is driving significant growth. Learn about the strategies we employ to create products that resonate with users.',
|
|
||||||
authors: [{ name: 'Erica Johns', avatar: '/static/images/avatar/6.jpg' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Design',
|
|
||||||
title: 'Embracing minimalism in modern design',
|
|
||||||
description:
|
|
||||||
'Minimalism is a key trend in modern design. Discover how our design team incorporates minimalist principles to create clean and impactful user experiences.',
|
|
||||||
authors: [{ name: 'Kate Morrison', avatar: '/static/images/avatar/7.jpg' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Company',
|
|
||||||
title: 'Cultivating a culture of innovation',
|
|
||||||
description:
|
|
||||||
'Innovation is at the heart of our company culture. Learn about the initiatives we have in place to foster creativity and drive groundbreaking solutions.',
|
|
||||||
authors: [{ name: 'Cindy Baker', avatar: '/static/images/avatar/3.jpg' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Engineering',
|
|
||||||
title: 'Advancing cybersecurity with next-gen solutions',
|
|
||||||
description:
|
|
||||||
'Our next-generation cybersecurity solutions are setting new standards in the industry. Discover how we protect our clients from evolving cyber threats.',
|
|
||||||
authors: [
|
|
||||||
{ name: 'Agnes Walker', avatar: '/static/images/avatar/4.jpg' },
|
|
||||||
{ name: 'Trevor Henderson', avatar: '/static/images/avatar/5.jpg' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Product',
|
|
||||||
title: 'Enhancing customer experience through innovation',
|
|
||||||
description:
|
|
||||||
'Our innovative approaches are enhancing customer experience. Learn about the new features and improvements that are delighting our users.',
|
|
||||||
authors: [{ name: 'Travis Howard', avatar: '/static/images/avatar/2.jpg' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Engineering',
|
|
||||||
title: 'Pioneering sustainable engineering solutions',
|
|
||||||
description:
|
|
||||||
"Learn about our commitment to sustainability and the innovative engineering solutions we're implementing to create a greener future. Discover the impact of our eco-friendly initiatives.",
|
|
||||||
authors: [
|
|
||||||
{ name: 'Agnes Walker', avatar: '/static/images/avatar/4.jpg' },
|
|
||||||
{ name: 'Trevor Henderson', avatar: '/static/images/avatar/5.jpg' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Product',
|
|
||||||
title: 'Maximizing efficiency with our latest product updates',
|
|
||||||
description:
|
|
||||||
'Our recent product updates are designed to help you maximize efficiency and achieve more. Get a detailed overview of the new features and improvements that can elevate your workflow.',
|
|
||||||
authors: [{ name: 'Travis Howard', avatar: '/static/images/avatar/2.jpg' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Design',
|
|
||||||
title: 'Designing for the future: trends and insights',
|
|
||||||
description:
|
|
||||||
'Stay ahead of the curve with the latest design trends and insights. Our design team shares their expertise on creating intuitive and visually stunning user experiences.',
|
|
||||||
authors: [{ name: 'Kate Morrison', avatar: '/static/images/avatar/7.jpg' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: 'Company',
|
|
||||||
title: "Our company's journey: milestones and achievements",
|
|
||||||
description:
|
|
||||||
"Take a look at our company's journey and the milestones we've achieved along the way. From humble beginnings to industry leader, discover our story of growth and success.",
|
|
||||||
authors: [{ name: 'Cindy Baker', avatar: '/static/images/avatar/3.jpg' }],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const StyledTypography = styled(Typography)({
|
const StyledTypography = styled(Typography)({
|
||||||
display: '-webkit-box',
|
display: '-webkit-box',
|
||||||
@@ -160,34 +80,75 @@ function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
|
|||||||
))}
|
))}
|
||||||
</AvatarGroup>
|
</AvatarGroup>
|
||||||
<Typography variant="caption">
|
<Typography variant="caption">
|
||||||
{authors.map((author) => author.name).join(', ')}
|
{authors.map((a) => a.name).join(', ')}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Typography variant="caption">July 14, 2021</Typography>
|
<Typography variant="caption">Recently Updated</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Latest() {
|
// ---- Latest component ---- //
|
||||||
const [focusedCardIndex, setFocusedCardIndex] = React.useState<number | null>(
|
interface LatestProps {
|
||||||
null,
|
articles: Article[];
|
||||||
|
onSelectArticle?: (index: number) => void;
|
||||||
|
onLoadMore?: (offset: number, limit: number) => Promise<void>; // optional async callback
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Latest({ articles, onSelectArticle, onLoadMore }: LatestProps) {
|
||||||
|
const [visibleCount, setVisibleCount] = React.useState(2);
|
||||||
|
const [loadingMore, setLoadingMore] = React.useState(false);
|
||||||
|
|
||||||
|
const displayedArticles = articles.slice(0, visibleCount);
|
||||||
|
|
||||||
|
// Intersection Observer ref
|
||||||
|
const loaderRef = React.useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!loaderRef.current) return;
|
||||||
|
|
||||||
|
const observer = new IntersectionObserver(
|
||||||
|
async (entries) => {
|
||||||
|
const first = entries[0];
|
||||||
|
if (first.isIntersecting && !loadingMore && visibleCount < articles.length) {
|
||||||
|
console.log('🟡 Intersection triggered — loading more blogs...');
|
||||||
|
setLoadingMore(true);
|
||||||
|
|
||||||
|
if (onLoadMore) {
|
||||||
|
console.log(`📡 Calling onLoadMore(offset=${visibleCount}, limit=2)`);
|
||||||
|
await onLoadMore(visibleCount, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleCount((prev) => {
|
||||||
|
const newCount = prev + 2;
|
||||||
|
console.log(`✅ Increasing visibleCount from ${prev} → ${newCount}`);
|
||||||
|
return newCount;
|
||||||
|
});
|
||||||
|
|
||||||
|
setLoadingMore(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ threshold: 0.5 }
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleFocus = (index: number) => {
|
const current = loaderRef.current;
|
||||||
setFocusedCardIndex(index);
|
observer.observe(current);
|
||||||
};
|
|
||||||
|
|
||||||
const handleBlur = () => {
|
console.log('👀 IntersectionObserver attached to loaderRef:', loaderRef.current);
|
||||||
setFocusedCardIndex(null);
|
|
||||||
|
return () => {
|
||||||
|
if (current) observer.unobserve(current);
|
||||||
|
console.log('🧹 IntersectionObserver detached');
|
||||||
};
|
};
|
||||||
|
}, [loadingMore, visibleCount, articles.length, onLoadMore]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Box>
|
||||||
<Typography variant="h2" gutterBottom>
|
<Typography variant="h2" gutterBottom>
|
||||||
Latest
|
Latest
|
||||||
</Typography>
|
</Typography>
|
||||||
<Grid container spacing={8} columns={12} sx={{ my: 4 }}>
|
<Grid container spacing={8} columns={12} sx={{ my: 4 }}>
|
||||||
{articleInfo.map((article, index) => (
|
{displayedArticles.map((article, index) => (
|
||||||
<Grid key={index} size={{ xs: 12, sm: 6 }}>
|
<Grid key={index} size={{ xs: 12, sm: 6 }}>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -201,20 +162,17 @@ export default function Latest() {
|
|||||||
<Typography gutterBottom variant="caption" component="div">
|
<Typography gutterBottom variant="caption" component="div">
|
||||||
{article.tag}
|
{article.tag}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<TitleTypography
|
<TitleTypography
|
||||||
gutterBottom
|
gutterBottom
|
||||||
variant="h6"
|
variant="h6"
|
||||||
onFocus={() => handleFocus(index)}
|
|
||||||
onBlur={handleBlur}
|
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className={focusedCardIndex === index ? 'Mui-focused' : ''}
|
onClick={() => onSelectArticle?.(index)}
|
||||||
>
|
>
|
||||||
{article.title}
|
{article.title}
|
||||||
<NavigateNextRoundedIcon
|
<NavigateNextRoundedIcon className="arrow" sx={{ fontSize: '1rem' }} />
|
||||||
className="arrow"
|
|
||||||
sx={{ fontSize: '1rem' }}
|
|
||||||
/>
|
|
||||||
</TitleTypography>
|
</TitleTypography>
|
||||||
|
|
||||||
<StyledTypography variant="body2" color="text.secondary" gutterBottom>
|
<StyledTypography variant="body2" color="text.secondary" gutterBottom>
|
||||||
{article.description}
|
{article.description}
|
||||||
</StyledTypography>
|
</StyledTypography>
|
||||||
@@ -224,9 +182,11 @@ export default function Latest() {
|
|||||||
</Grid>
|
</Grid>
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'row', pt: 4 }}>
|
|
||||||
<Pagination hidePrevButton hideNextButton count={10} boundaryCount={10} />
|
{/* Infinite scroll loader */}
|
||||||
|
<Box ref={loaderRef} sx={{ display: 'flex', justifyContent: 'center', py: 3 }}>
|
||||||
|
{loadingMore && <CircularProgress size={28} />}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user