astro-loader-hashnode
Version:
Astro content loader for seamlessly integrating Hashnode blog posts into your Astro website using the Content Layer API
150 lines (149 loc) • 4.52 kB
TypeScript
/**
* Posts Loader - Handles Hashnode blog posts
*/
import { BaseHashnodeLoader } from './base.js';
import type { PostsLoaderOptions } from '../types/loader.js';
import type { HashnodePost } from '../types/hashnode.js';
/**
* Posts Loader Class
*/
export declare class PostsLoader extends BaseHashnodeLoader {
private options;
constructor(options: PostsLoaderOptions);
/**
* Fetch posts data from Hashnode API
*/
protected fetchData(): Promise<HashnodePost[]>;
/**
* Transform Hashnode post to Astro content format
*/
protected transformItem(post: HashnodePost): {
id: string;
cuid: string | undefined;
title: string;
subtitle: string;
brief: string;
slug: string;
url: string | undefined;
content: {
html: string;
markdown: string | undefined;
};
publishedAt: Date;
updatedAt: Date | undefined;
readingTime: number;
wordCount: undefined;
views: number;
reactions: number;
comments: number;
replies: number;
isDraft: boolean;
hasLatex: boolean;
hashnodeId: string;
hashnodeUrl: string | undefined;
author: {
id: string;
name: string;
username: string;
profilePicture: string | undefined;
bio: string | undefined;
url: string | undefined;
social: {
website: string | undefined;
github: string | undefined;
twitter: string | undefined;
linkedin: string | undefined;
};
followersCount: number | undefined;
};
coAuthors: {
id: string;
name: string;
username: string;
profilePicture: string | undefined;
bio: string | undefined;
url: undefined;
social: undefined;
followersCount: undefined;
}[] | undefined;
coverImage: {
url: string;
alt: undefined;
attribution: string | undefined;
isPortrait: true | undefined;
isAttributionHidden: true | undefined;
} | undefined;
tags: {
id: string | undefined;
name: string;
slug: string;
logo: undefined;
tagline: undefined;
followersCount: undefined;
}[];
series: {
id: string;
name: string | undefined;
slug: string | undefined;
} | undefined;
seo: {
title: string;
description: string;
};
ogMetaData: {
image: string;
} | undefined;
tableOfContents: {
isEnabled: boolean;
items: {
id: string;
level: number;
parentId: string | undefined;
slug: string;
title: string;
}[];
} | undefined;
commentsData: {
totalCount: number;
comments: {
id: string;
dateAdded: string;
totalReactions: number;
content: {
html: string;
markdown: string | undefined;
};
author: {
id: string;
name: string;
username: string;
profilePicture: string | undefined;
bio: undefined;
url: undefined;
social: undefined;
followersCount: undefined;
};
replies: import("../index.js").HashnodeComment[] | undefined;
}[];
} | undefined;
preferences: {
disableComments: true | undefined;
stickCoverToBottom: true | undefined;
pinnedToBlog: true | undefined;
isDelisted: true | undefined;
};
publication: undefined;
};
/**
* Generate ID for post (prefer slug over cuid over id)
*/
protected generateId(post: HashnodePost): string;
}
/**
* Create a posts loader
*/
export declare function createPostsLoader(options: PostsLoaderOptions): PostsLoader;
/**
* Create an Astro Loader for posts
*/
export declare function postsLoader(options: PostsLoaderOptions): import("astro/loaders").Loader;