Skip to content

Commit

Permalink
finish card tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
ammakr committed Dec 5, 2024
1 parent c694b45 commit faad035
Show file tree
Hide file tree
Showing 13 changed files with 696 additions and 384 deletions.
2 changes: 1 addition & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import tailwind from "@astrojs/tailwind";
// https://astro.build/config
export default defineConfig({
site: "https://athenaos.org/",
output: "static",
output: "hybrid",
integrations: [
starlight({
title: "Athena OS",
Expand Down
67 changes: 67 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { defineAction } from "astro:actions";
import { z } from "astro:schema";

let bearerToken = import.meta.env.STRAPI_WRITE_TOKEN;

const getDownloadCounts = async () => {
try {
const response = await fetch(
`https://cms.athenaos.org/api/download-counts-list`,
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${bearerToken}`,
},
}
);
const result = await response.json();
return result;
} catch (error) {
console.error("Error fetching data:", error);
}
};

const increaseDownloadCount = async (id: string) => {
let data = [
{ id: "7", download_type: "docker" },
{ id: "1", download_type: "iso" },
{ id: "5", download_type: "virtualbox" },
{ id: "3", download_type: "vmware" },
{ id: "9", download_type: "wsl" },
];

try {
let countId = data.find((item) => item.download_type === id)?.id;

const response = await fetch(
`https://cms.athenaos.org/api/download-count/${countId}/increment`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${bearerToken}`,
},
}
);
const result = await response.json();
return result;
} catch (error) {
console.error("Error increasing download count:", error);
}
};

export const server = {
getDownloadCount: defineAction({
handler: async () => {
return await getDownloadCounts();
},
}),
increaseCount: defineAction({
input: z.object({
id: z.string(),
}),
handler: async (input) => {
return await increaseDownloadCount(input.id);
},
}),
};
201 changes: 0 additions & 201 deletions src/components/DownloadCards.jsx

This file was deleted.

Loading

0 comments on commit faad035

Please sign in to comment.