Add author auth, forking, tags, and stats tracking
Introduce token-based author authentication (register/verify API), skill forking with EditGate protection, tag metadata on skills, and download/push stats. Enhanced push scripts with token auth and per-skill filtering. Updated UI with stats, tags, and author info on skill cards.
This commit is contained in:
36
src/pages/[slug]/i.ts
Normal file
36
src/pages/[slug]/i.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
import { getSkill } from '../../lib/skills';
|
||||
import { isPowerShell } from '../../lib/sync';
|
||||
|
||||
export const GET: APIRoute = async ({ params, url, request }) => {
|
||||
const { slug } = params;
|
||||
const skill = await getSkill(slug!);
|
||||
if (!skill) {
|
||||
return new Response('Skill not found', { status: 404 });
|
||||
}
|
||||
|
||||
const origin = url.origin;
|
||||
const ps = isPowerShell(request);
|
||||
|
||||
const script = ps
|
||||
? [
|
||||
'$ErrorActionPreference = "Stop"',
|
||||
'$Dir = ".claude\\skills"',
|
||||
'New-Item -ItemType Directory -Force -Path $Dir | Out-Null',
|
||||
`Invoke-WebRequest -Uri "${origin}/${slug}" -OutFile (Join-Path $Dir "${slug}.md")`,
|
||||
`Write-Host "✓ Installed ${skill.name} to $Dir\\${slug}.md"`,
|
||||
'',
|
||||
].join('\n')
|
||||
: [
|
||||
'#!/usr/bin/env bash',
|
||||
'set -euo pipefail',
|
||||
'mkdir -p .claude/skills',
|
||||
`curl -fsSL "${origin}/${slug}" -o ".claude/skills/${slug}.md"`,
|
||||
`echo "✓ Installed ${skill.name} to .claude/skills/${slug}.md"`,
|
||||
'',
|
||||
].join('\n');
|
||||
|
||||
return new Response(script, {
|
||||
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user