astro-loader-hashnode
Version:
Astro content loader for seamlessly integrating Hashnode blog posts into your Astro website using the Content Layer API
70 lines (69 loc) • 1.85 kB
TypeScript
/**
* Drafts Loader - Handles Hashnode draft posts (requires authentication)
*/
import { BaseHashnodeLoader } from './base.js';
import type { DraftsLoaderOptions } from '../types/loader.js';
import type { HashnodePost } from '../types/hashnode.js';
/**
* Drafts Loader Class
*/
export declare class DraftsLoader extends BaseHashnodeLoader {
private options;
constructor(options: DraftsLoaderOptions);
/**
* Fetch drafts data from Hashnode API
*/
protected fetchData(): Promise<HashnodePost[]>;
/**
* Transform Hashnode draft to Astro content format
*/
protected transformItem(draft: HashnodePost): {
id: string;
title: string;
subtitle: string;
content: string;
canonicalUrl: string;
updatedAt: Date;
createdAt: Date;
author: {
id: string;
name: string;
username: string;
profilePicture: string;
};
coverImage: {
url: string;
} | undefined;
tags: {
id: string;
name: string;
slug: string;
}[];
tableOfContents: never[];
isDraft: boolean;
lastSaved: Date;
raw: {
id: string | null;
};
};
/**
* Generate ID for draft
*/
protected generateId(draft: HashnodePost): string;
/**
* Generate fallback ID when no proper ID is available
*/
private generateFallbackId;
/**
* Simple hash function for generating IDs
*/
private simpleHash;
}
/**
* Create a drafts loader
*/
export declare function createDraftsLoader(options: DraftsLoaderOptions): DraftsLoader;
/**
* Create an Astro Loader for drafts
*/
export declare function draftsLoader(options: DraftsLoaderOptions): import("astro/loaders").Loader;