mirror of
https://github.com/dathere/ckanaction.git
synced 2025-11-09 14:19:49 +00:00
feat(docs): initial interactive ckanaction docs web app
This commit is contained in:
parent
945fc6dca1
commit
39c573a5a4
27 changed files with 1507 additions and 0 deletions
24
docs/lib/layout.shared.tsx
Normal file
24
docs/lib/layout.shared.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||
import { GiftIcon } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* Shared layout configurations
|
||||
*
|
||||
* you can customise layouts individually from:
|
||||
* Home Layout: app/(home)/layout.tsx
|
||||
* Docs Layout: app/docs/layout.tsx
|
||||
*/
|
||||
export function baseOptions(): BaseLayoutProps {
|
||||
return {
|
||||
nav: {
|
||||
title: (
|
||||
<>
|
||||
<GiftIcon />
|
||||
ckanaction
|
||||
</>
|
||||
),
|
||||
},
|
||||
// see https://fumadocs.dev/docs/ui/navigation/links
|
||||
links: [],
|
||||
};
|
||||
}
|
||||
39
docs/lib/openapi.ts
Normal file
39
docs/lib/openapi.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { createOpenAPI } from 'fumadocs-openapi/server';
|
||||
|
||||
export const openapi = createOpenAPI({
|
||||
input: ["./lib/openapi.yml"],
|
||||
generateCodeSamples(endpoint) {
|
||||
return [
|
||||
{
|
||||
lang: 'curl',
|
||||
label: 'cURL',
|
||||
source: false,
|
||||
},
|
||||
{
|
||||
lang: 'javascript',
|
||||
label: 'JavaScript',
|
||||
source: false,
|
||||
},
|
||||
{
|
||||
lang: 'go',
|
||||
label: 'Go',
|
||||
source: false,
|
||||
},
|
||||
{
|
||||
lang: 'python',
|
||||
label: 'Python',
|
||||
source: false,
|
||||
},
|
||||
{
|
||||
lang: 'java',
|
||||
label: 'Java',
|
||||
source: false,
|
||||
},
|
||||
{
|
||||
lang: 'c#',
|
||||
label: 'C#',
|
||||
source: false,
|
||||
},
|
||||
];
|
||||
},
|
||||
});
|
||||
87
docs/lib/openapi.yml
Normal file
87
docs/lib/openapi.yml
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
info:
|
||||
title: ckanaction
|
||||
security:
|
||||
- apiTokenHeader:
|
||||
description: CKAN API token
|
||||
type: apiKey
|
||||
name: Authorization
|
||||
in: header
|
||||
components:
|
||||
securitySchemes:
|
||||
apiTokenHeader:
|
||||
type: apiKey
|
||||
in: header
|
||||
name: Authorization
|
||||
description: CKAN API token
|
||||
servers:
|
||||
- url: http://localhost:5000/api/3/action
|
||||
- url: '{protocol}://{domain}/api/3/action'
|
||||
description: Your custom server running the CKAN Actions API (v3).
|
||||
variables:
|
||||
protocol:
|
||||
enum:
|
||||
- https
|
||||
- http
|
||||
default: https
|
||||
domain:
|
||||
default: 'demo.ckan.org'
|
||||
paths:
|
||||
'/status_show':
|
||||
get:
|
||||
operationId: /status_show
|
||||
summary: /status_show
|
||||
description: This endpoint shows information about the CKAN instance.
|
||||
x-codeSamples:
|
||||
- lang: rust
|
||||
label: Rust SDK (ckanaction)
|
||||
source: |
|
||||
use dotenvy::dotenv;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Load environment variables from .env file
|
||||
dotenv()?;
|
||||
|
||||
// Initialize and build CKAN struct
|
||||
let ckan = ckanaction::CKAN::builder()
|
||||
.url("http://localhost:5000")
|
||||
.token(dotenvy::var("CKAN_API_TOKEN")?)
|
||||
.build();
|
||||
|
||||
// Send request to /status_show and print output
|
||||
let result = ckan.status_show().await?;
|
||||
println!("{result:#?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
'/package_list':
|
||||
get:
|
||||
operationId: /package_list
|
||||
summary: /package_list
|
||||
description: This endpoint lists CKAN resources (limit 10).
|
||||
x-codeSamples:
|
||||
- lang: rust
|
||||
label: Rust SDK (ckanaction)
|
||||
source: |
|
||||
use dotenvy::dotenv;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Load environment variables from .env file
|
||||
dotenv()?;
|
||||
|
||||
// Initialize and build CKAN struct
|
||||
let ckan = ckanaction::CKAN::builder()
|
||||
.url("http://localhost:5000")
|
||||
.token(dotenvy::var("CKAN_API_TOKEN")?)
|
||||
.build();
|
||||
|
||||
// Send request to /package_list and print output
|
||||
let result = ckan.package_list()
|
||||
.limit(5) // <-- This is an optional parameter you can remove
|
||||
.call()
|
||||
.await?;
|
||||
println!("{result:#?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
28
docs/lib/source.ts
Normal file
28
docs/lib/source.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { docs } from '@/.source';
|
||||
import { type InferPageType, loader } from 'fumadocs-core/source';
|
||||
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
|
||||
import { openapiPlugin } from 'fumadocs-openapi/server';
|
||||
|
||||
// See https://fumadocs.dev/docs/headless/source-api for more info
|
||||
export const source = loader({
|
||||
baseUrl: '/docs',
|
||||
source: docs.toFumadocsSource(),
|
||||
plugins: [lucideIconsPlugin(), openapiPlugin()],
|
||||
});
|
||||
|
||||
export function getPageImage(page: InferPageType<typeof source>) {
|
||||
const segments = [...page.slugs, 'image.png'];
|
||||
|
||||
return {
|
||||
segments,
|
||||
url: `/og/docs/${segments.join('/')}`,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getLLMText(page: InferPageType<typeof source>) {
|
||||
const processed = await page.data.getText('processed');
|
||||
|
||||
return `# ${page.data.title} (${page.url})
|
||||
|
||||
${processed}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue