10 Commits
0.0.2 ... 0.0.5

Author SHA1 Message Date
13d52ec590 quotes to prevent accidental parsing of //
All checks were successful
continuous-integration/drone/tag Build is passing
2025-11-07 21:11:14 +05:30
71ce77980d enabled Latest.tsx 2025-11-07 20:50:30 +05:30
5943c08e73 bumped up to version 0.0.4
All checks were successful
continuous-integration/drone/tag Build is passing
2025-11-07 20:35:21 +05:30
2b26d5cf24 adding envs for drone 2025-11-07 20:34:58 +05:30
bff42d0f0b fixes for reading from env 2025-11-07 20:34:47 +05:30
38dc112d0a ignoring .env file as env shouldn't be in git 2025-11-07 20:17:44 +05:30
939a7eaba2 reading from blog api 2025-11-07 20:17:19 +05:30
e660c2bcb1 vite env interface 2025-11-07 20:17:07 +05:30
033f82208a only build when tag is pushed 2025-11-07 20:06:37 +05:30
e38d9ed53b using busy box image instead of alpine for httpd server
All checks were successful
continuous-integration/drone/tag Build is passing
2025-10-31 19:51:41 +05:30
8 changed files with 73 additions and 188 deletions

View File

@@ -108,6 +108,9 @@ steps:
- name: run-container
image: docker:24
environment:
API_BASE_URL:
from_secret: API_BASE_URL
volumes:
- name: dockersock
path: /var/run/docker.sock
@@ -120,6 +123,7 @@ steps:
--name blog \
-p 3002:3000 \
-e NODE_ENV=production \
-e VITE_API_BASE_URL="$API_BASE_URL" \
--restart always \
apps/blog:$IMAGE_TAG
@@ -127,4 +131,3 @@ steps:
trigger:
event:
- tag
- custom

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.env
# dependencies
node_modules

View File

@@ -16,8 +16,8 @@ COPY . .
# Build the app
RUN npm run build
# Stage 2: Production image
FROM alpine:latest
# Stage 2: Static file server (BusyBox)
FROM busybox:latest
WORKDIR /app

View File

@@ -1,6 +1,6 @@
{
"name": "material-ui-vite",
"version": "7.0.0",
"name": "aetoskia-blog-app",
"version": "0.0.4",
"private": true,
"scripts": {
"dev": "vite",

View File

@@ -59,7 +59,10 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
sx={{ display: 'flex', flexDirection: 'column', my: 16, gap: 4 }}
>
{selectedArticle === null ? (
<MainContent articles={articles} onSelectArticle={handleSelectArticle} />
<>
<MainContent articles={articles} onSelectArticle={handleSelectArticle} />
<Latest articles={articles.slice(0, 3)} /> {/* show 3 most recent */}
</>
) : (
<Article article={articles[selectedArticle]} onBack={handleBack} />
)}

View File

@@ -7,88 +7,8 @@ import Pagination from '@mui/material/Pagination';
import Typography from '@mui/material/Typography';
import { styled } from '@mui/material/styles';
import NavigateNextRoundedIcon from '@mui/icons-material/NavigateNextRounded';
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)({
display: '-webkit-box',
@@ -160,26 +80,28 @@ function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
))}
</AvatarGroup>
<Typography variant="caption">
{authors.map((author) => author.name).join(', ')}
{authors.map((a) => a.name).join(', ')}
</Typography>
</Box>
<Typography variant="caption">July 14, 2021</Typography>
<Typography variant="caption">Recently Updated</Typography>
</Box>
);
}
export default function Latest() {
const [focusedCardIndex, setFocusedCardIndex] = React.useState<number | null>(
null,
);
// ---- Latest component ---- //
interface LatestProps {
articles: Article[];
onSelectArticle?: (index: number) => void;
}
const handleFocus = (index: number) => {
setFocusedCardIndex(index);
};
export default function Latest({ articles, onSelectArticle }: LatestProps) {
const [focusedCardIndex, setFocusedCardIndex] = React.useState<number | null>(null);
const handleBlur = () => {
setFocusedCardIndex(null);
};
const handleFocus = (index: number) => setFocusedCardIndex(index);
const handleBlur = () => setFocusedCardIndex(null);
// limit to 4-6 items for visual balance
const displayedArticles = articles.slice(0, 6);
return (
<div>
@@ -187,7 +109,7 @@ export default function Latest() {
Latest
</Typography>
<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 }}>
<Box
sx={{
@@ -201,12 +123,14 @@ export default function Latest() {
<Typography gutterBottom variant="caption" component="div">
{article.tag}
</Typography>
<TitleTypography
gutterBottom
variant="h6"
tabIndex={0}
onFocus={() => handleFocus(index)}
onBlur={handleBlur}
tabIndex={0}
onClick={() => onSelectArticle?.(index)}
className={focusedCardIndex === index ? 'Mui-focused' : ''}
>
{article.title}

View File

@@ -2,18 +2,26 @@ import React, { createContext, useState, useContext, useEffect } from 'react';
import axios from 'axios';
interface Author {
_id?: string | null;
username: string;
name: string;
email: string;
avatar: string;
is_active: boolean;
created_at?: string;
updated_at?: string;
}
export interface Article {
id: string;
_id?: string | null;
created_at: string;
updated_at: string;
img: string;
tag: string;
title: string;
description: string;
img: string;
content: string;
authors: Author[];
date?: string;
}
interface ArticleContextType {
@@ -23,7 +31,9 @@ interface ArticleContextType {
refreshArticles: () => Promise<void>;
}
const Article = createContext<ArticleContextType | undefined>(undefined);
const ArticleContext = createContext<ArticleContextType | undefined>(undefined);
const API_BASE = import.meta.env.VITE_API_BASE_URL;
export const ArticleProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [articles, setArticles] = useState<Article[]>([]);
@@ -32,88 +42,23 @@ export const ArticleProvider: React.FC<{ children: React.ReactNode }> = ({ child
const fetchArticles = async () => {
try {
// ✅ Use static defaults first
const defaults = [
{
img: 'https://picsum.photos/800/450?random=1',
tag: 'Engineering',
title: 'Revolutionizing software development with cutting-edge tools',
description:
'Our latest engineering tools are designed to streamline workflows and boost productivity. Discover how these innovations are transforming the software development landscape.',
content:
'Our latest engineering tools are designed to streamline workflows and boost productivity. Discover how these innovations are transforming the software development landscape.',
authors: [
{ name: 'Remy Sharp', avatar: '/static/images/avatar/1.jpg' },
{ name: 'Travis Howard', avatar: '/static/images/avatar/2.jpg' },
],
},
{
img: 'https://picsum.photos/800/450?random=2',
tag: 'Product',
title: 'Innovative product features that drive success',
description:
'Explore the key features of our latest product release that are helping businesses achieve their goals. From user-friendly interfaces to robust functionality, learn why our product stands out.',
content:
'Explore the key features of our latest product release that are helping businesses achieve their goals. From user-friendly interfaces to robust functionality, learn why our product stands out.',
authors: [{ name: 'Erica Johns', avatar: '/static/images/avatar/6.jpg' }],
},
{
img: 'https://picsum.photos/800/450?random=3',
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.',
content:
'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' }],
},
{
img: 'https://picsum.photos/800/450?random=4',
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.",
content:
"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' }],
},
{
img: 'https://picsum.photos/800/450?random=45',
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.",
content:
"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' },
],
},
{
img: 'https://picsum.photos/800/450?random=6',
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.',
content:
'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' }],
},
];
// ✅ For now: only use defaults
// @ts-ignore
setArticles(defaults);
setLoading(false);
// 🔜 Optional: uncomment this to fetch from API when backend is ready
/*
setLoading(true);
const res = await axios.get('/articles');
setArticles(res.data);
*/
setError(null);
// ✅ Use correct full endpoint from OpenAPI spec
const res = await axios.get<Article[]>(`${API_BASE}/articles`, {
params: { skip: 0, limit: 10 },
});
// ✅ Normalize if backend sends _id instead of id
const formatted = res.data.map((a) => ({
...a,
id: a._id || undefined,
}));
setArticles(formatted);
} catch (err: any) {
console.error('Failed to fetch articles:', err);
setError(err.message || 'Failed to fetch articles');
} finally {
setLoading(false);
@@ -125,14 +70,14 @@ export const ArticleProvider: React.FC<{ children: React.ReactNode }> = ({ child
}, []);
return (
<Article.Provider value={{ articles, loading, error, refreshArticles: fetchArticles }}>
<ArticleContext.Provider value={{ articles, loading, error, refreshArticles: fetchArticles }}>
{children}
</Article.Provider>
</ArticleContext.Provider>
);
};
export const useArticles = (): ArticleContextType => {
const ctx = useContext(Article);
const ctx = useContext(ArticleContext);
if (!ctx) throw new Error('useArticles must be used inside ArticleProvider');
return ctx;
};

9
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_BASE_URL: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}