Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / packages/newsletter/src/providers/substack.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | packages/newsletter/src/providers/substack.ts |
| Original SHA-256 | 2a069d98c97f2554bf0f324440a41d89ab2d5b14227c63785510c40f90e104df |
| Git blob SHA | 183752e43768994a4109ab4e15fdf97cd255d466 |
| Reading-copy SHA-256 | 2a069d98c97f2554bf0f324440a41d89ab2d5b14227c63785510c40f90e104df |
Recovered source transcript
Download complete source text ↓68 lines · 1.9 KB
import type {
NewsletterProviderInterface,
NewsletterSubscriber,
SubscribeRequest,
SubscribeResponse,
SubstackConfig
} from '../types'
export class SubstackProvider implements NewsletterProviderInterface {
private config: SubstackConfig
constructor(config: SubstackConfig) {
this.config = config
if (!config.publicationUrl) {
throw new Error('Substack publication URL is required')
}
}
async subscribe(_data: SubscribeRequest): Promise<SubscribeResponse> {
// Substack doesn't have an API - it uses an embedded iframe
// This provider is mainly for configuration and generating the embed URL
this.config.logger?.warn('Substack uses iframe embedding, not API calls', {
tags: { type: 'newsletter' }
})
return {
success: false,
message: 'Substack requires iframe embedding. Use getEmbedUrl() to get the iframe source.',
error: 'IFRAME_ONLY'
}
}
/**
* Get the Substack embed URL for iframe integration
*/
getEmbedUrl(): string {
const publicationDomain = this.config.publicationUrl
.replace(/^https?:\/\//, '')
.replace(/\/$/, '')
return this.config.embedUrl || `https://${publicationDomain}/embed`
}
/**
* Indicates this provider only works with iframe embedding
*/
isIframeOnly(): boolean {
return true
}
async unsubscribe(_email: string): Promise<{ success: boolean; message: string }> {
// Substack doesn't provide a public API for unsubscribing
// Users must use the unsubscribe link in their emails
return {
success: false,
message: 'Please use the unsubscribe link in your Substack emails to unsubscribe'
}
}
async getSubscriber(_email: string): Promise<NewsletterSubscriber | null> {
// Substack doesn't provide a public API for getting subscriber info
this.config.logger?.warn('Substack does not provide API for getting subscriber info', {
tags: { type: 'newsletter' }
})
return null
}
}