Skip to content

Commit faad035

Browse files
committed
finish card tabs
1 parent c694b45 commit faad035

File tree

13 files changed

+696
-384
lines changed

13 files changed

+696
-384
lines changed

astro.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import tailwind from "@astrojs/tailwind";
66
// https://astro.build/config
77
export default defineConfig({
88
site: "https://athenaos.org/",
9-
output: "static",
9+
output: "hybrid",
1010
integrations: [
1111
starlight({
1212
title: "Athena OS",

src/actions/index.ts

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { defineAction } from "astro:actions";
2+
import { z } from "astro:schema";
3+
4+
let bearerToken = import.meta.env.STRAPI_WRITE_TOKEN;
5+
6+
const getDownloadCounts = async () => {
7+
try {
8+
const response = await fetch(
9+
`https://cms.athenaos.org/api/download-counts-list`,
10+
{
11+
headers: {
12+
"Content-Type": "application/json",
13+
Authorization: `Bearer ${bearerToken}`,
14+
},
15+
}
16+
);
17+
const result = await response.json();
18+
return result;
19+
} catch (error) {
20+
console.error("Error fetching data:", error);
21+
}
22+
};
23+
24+
const increaseDownloadCount = async (id: string) => {
25+
let data = [
26+
{ id: "7", download_type: "docker" },
27+
{ id: "1", download_type: "iso" },
28+
{ id: "5", download_type: "virtualbox" },
29+
{ id: "3", download_type: "vmware" },
30+
{ id: "9", download_type: "wsl" },
31+
];
32+
33+
try {
34+
let countId = data.find((item) => item.download_type === id)?.id;
35+
36+
const response = await fetch(
37+
`https://cms.athenaos.org/api/download-count/${countId}/increment`,
38+
{
39+
method: "POST",
40+
headers: {
41+
"Content-Type": "application/json",
42+
Authorization: `Bearer ${bearerToken}`,
43+
},
44+
}
45+
);
46+
const result = await response.json();
47+
return result;
48+
} catch (error) {
49+
console.error("Error increasing download count:", error);
50+
}
51+
};
52+
53+
export const server = {
54+
getDownloadCount: defineAction({
55+
handler: async () => {
56+
return await getDownloadCounts();
57+
},
58+
}),
59+
increaseCount: defineAction({
60+
input: z.object({
61+
id: z.string(),
62+
}),
63+
handler: async (input) => {
64+
return await increaseDownloadCount(input.id);
65+
},
66+
}),
67+
};

src/components/DownloadCards.jsx

-201
This file was deleted.

0 commit comments

Comments
 (0)