@@ -265,7 +265,7 @@ const { links } = Astro.props
265
265
}
266
266
private readonly downloadCount: HTMLElement
267
267
private readonly atlasVersion = '0.4.1'
268
- private readonly apiEndpoint = 'https://api.atlasos.net/atlas '
268
+ private readonly apiEndpoint = 'https://api.atlasos.net'
269
269
270
270
constructor() {
271
271
const elements = {
@@ -344,11 +344,13 @@ const { links } = Astro.props
344
344
345
345
private async fetchDownloadCount(): Promise<number | null> {
346
346
try {
347
- const response = await fetch(`${ this.apiEndpoint}/stats` )
347
+ const response = await fetch(this.apiEndpoint)
348
348
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)
349
349
350
350
const data = await response.json()
351
- return data.downloads || 0
351
+ const atlasDownload = data.find((download: { version: string }) => download.version === 'atlas')
352
+
353
+ return atlasDownload?.count || 0
352
354
} catch (error) {
353
355
console.error('Error fetching download count:', error)
354
356
return null
@@ -357,9 +359,8 @@ const { links } = Astro.props
357
359
358
360
private async incrementDownloadCount(): Promise<void> {
359
361
try {
360
- const response = await fetch(`${this.apiEndpoint}/increment`, {
361
- method: 'POST',
362
- headers: { 'Content-Type': 'application/json' }
362
+ const response = await fetch(`${this.apiEndpoint}/atlas/increment`, {
363
+ method: 'POST'
363
364
})
364
365
365
366
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)
@@ -374,7 +375,11 @@ const { links } = Astro.props
374
375
375
376
window.open(`https://cdn.jsdelivr.net/atlas/${this.atlasVersion}/AtlasPlaybook_v${this.atlasVersion}.zip`, '_self')
376
377
377
- await this.incrementDownloadCount()
378
+ try {
379
+ await this.incrementDownloadCount()
380
+ } catch (error) {
381
+ console.error('Failed to increment download count:', error)
382
+ }
378
383
379
384
setTimeout(() => {
380
385
this.buttons.playbook.innerHTML = originalContent
0 commit comments