Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
happychuks committed Aug 17, 2024
2 parents 6b3749b + b1ce3af commit d237b8b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 93 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/deploy.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ vpsSetup.md
.DS_Store
test.rest
db.sqlite3
old-backup-db.sqlite3
old-backup-db.sqlite3

38 changes: 23 additions & 15 deletions research/src/pages/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,52 @@ try {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
article = await response.json();
console.log("Article data:", article);
const data = await response.json();
if (data && data.success && data.data) {
article = data as Article;
} else {
throw new Error("Invalid article data");
}
} catch (error) {
console.error("Error fetching article:", error);
}
---

<Layout
title={article?.data?.title ?? ""}
description={article?.data?.description ?? ""}
description={article?.data?.summary ?? ""}
>
<main class="">
<a href="/">Back</a>
{
article?.data ? (
article ? (
<article>
<div>
<ul>
{article?.data?.categories.map((category) => (
<li>
<a href={`/${category.name}`}>
{category.name}
</a>
</li>
))}
{article.data?.categories.map(
(category: { name: string }) => (
<li>
<a href={`/categories/${category.name}`}>
{category.name}
</a>
</li>
),
)}
</ul>
<h1>{article.data.title}</h1>
<p>{article.data.summary}</p>
<h1>{article.data?.title}</h1>
<p>{article.data?.summary}</p>

<div>
<img
src={`${article.data.thumb}`}
src={`${article.data?.thumb}`}
alt=""
width="720"
height="480"
/>
</div>
<div set:html={article.data.content} />
<div set:html={article.data?.content} />
</div>
</article>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Layout from "../../layouts/Layout.astro";
interface Category {
name: string;
Expand Down
81 changes: 38 additions & 43 deletions research/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,55 @@
import Layout from "../layouts/Layout.astro";
interface Category {
name: string;
name: string;
}
interface Article {
id: string;
title: string;
authors: { username: string }[];
content: string;
views: string;
summary: string;
categories: Category[];
thumb: string;
id: string;
title: string;
authors: { username: string }[];
content: string;
views: string;
summary: string;
categories: Category[];
thumb: string;
}
let articles: Article[] = [];
try {
const response = await fetch("http://127.0.0.1:8000/api/articles");
articles = await response.json();
const response = await fetch("http://127.0.0.1:8000/api/articles");
articles = await response.json();
} catch (error) {
console.error(error);
console.error(error);
}
---

<Layout
title="2077 Research"
description="Deep dives and technical analyses on Ethereum infrastructure, protocols, and applications"
title="2077 Research"
description="Deep dives and technical analyses on Ethereum infrastructure, protocols, and applications"
>
<main>
<ul>
{
articles.map((article: Article) => (
<li data-key={article.id}>
<img
src={`${article.thumb}`}
alt=""
width="720"
height="480"
/>
<ul>
{article?.categories.map((category) => (
<li>
<a href={`/${category.name}`}>{category.name}</a>
</li>
))}
</ul>
<h2>{article.title}</h2>
<>
<p>{article.summary}</p>
<a href={`/${article.id}`}>Read post</a>
</>
</li>
))
}
</ul>
</main>
</Layout>
<main>
<ul>
{
articles.map((article: Article) => (
<li data-key={article.id}>
<img src={`${article.thumb}`} alt="" width="720" height="480" />
<ul>
{article?.categories.map((category) => (
<li>
<a href={`/categories/${category.name}`}>{category.name}</a>
</li>
))}
</ul>
<h2>{article.title}</h2>
<>
<p>{article.summary}</p>
<a href={`/${article.id}`}>Read post</a>
</>
</li>
))
}
</ul>
</main>
</Layout>

0 comments on commit d237b8b

Please sign in to comment.