@xexr/blog-platform 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,14 +1,42 @@
1
1
  import { PublishedArticle, PublishedSite, PublishResult, PublishedAuthor } from './types/index.mjs';
2
2
  export { PublishPayload } from './types/index.mjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import * as class_variance_authority_types from 'class-variance-authority/types';
5
4
  import * as React from 'react';
5
+ import { CSSProperties } from 'react';
6
+ import * as class_variance_authority_types from 'class-variance-authority/types';
6
7
  import { VariantProps } from 'class-variance-authority';
7
8
  import { ClassValue } from 'clsx';
8
9
  import { NextRequest, NextResponse } from 'next/server';
9
10
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
10
11
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
11
12
 
13
+ interface BlogTheme {
14
+ accentColor?: string;
15
+ accentHoverColor?: string;
16
+ accentBackgroundColor?: string;
17
+ accentBorderColor?: string;
18
+ }
19
+ interface TocItem {
20
+ id: string;
21
+ text: string;
22
+ level: 2 | 3;
23
+ }
24
+ interface ArticleDateMeta {
25
+ publishedDateLabel: string;
26
+ publishedRelativeLabel: string;
27
+ updatedDateLabel: string;
28
+ isUpdated: boolean;
29
+ }
30
+ type BlogThemeStyle = CSSProperties & {
31
+ "--blog-accent": string;
32
+ "--blog-accent-hover": string;
33
+ "--blog-accent-bg": string;
34
+ "--blog-accent-border": string;
35
+ };
36
+ declare function getBlogThemeStyle(theme?: BlogTheme): BlogThemeStyle;
37
+ declare function formatArticleDateMeta(publishedAt: string, updatedAt: string): ArticleDateMeta;
38
+ declare function extractTableOfContents(markdown: string): TocItem[];
39
+
12
40
  interface BlogHomePageProps {
13
41
  articles: PublishedArticle[];
14
42
  siteName?: string;
@@ -18,12 +46,16 @@ interface BlogHomePageProps {
18
46
  site?: PublishedSite;
19
47
  /** Whether to include structured data */
20
48
  includeStructuredData?: boolean;
49
+ /** Public path where this blog is mounted, e.g. "/blog" or "/new-blog". */
50
+ basePath?: string;
21
51
  /** Pagination configuration */
22
52
  pagination?: {
23
53
  currentPage: number;
24
54
  totalPages: number;
25
55
  baseUrl?: string;
26
56
  };
57
+ /** Optional theme values for host-site brand integration. */
58
+ theme?: BlogTheme;
27
59
  }
28
60
  /**
29
61
  * Blog home page component that displays a list of published articles.
@@ -32,7 +64,7 @@ interface BlogHomePageProps {
32
64
  * @xexr/blog-platform package. It provides a clean, SEO-friendly
33
65
  * article listing with proper metadata.
34
66
  */
35
- declare function BlogHomePage({ articles, siteName, siteTagline, className, site, includeStructuredData, pagination, }: BlogHomePageProps): react_jsx_runtime.JSX.Element;
67
+ declare function BlogHomePage({ articles, siteName, siteTagline, className, site, includeStructuredData, basePath, pagination, theme, }: BlogHomePageProps): react_jsx_runtime.JSX.Element;
36
68
  /**
37
69
  * Generate metadata for the blog home page for SEO optimization.
38
70
  * This function should be used in the Next.js metadata API.
@@ -40,7 +72,7 @@ declare function BlogHomePage({ articles, siteName, siteTagline, className, site
40
72
  declare function generateBlogHomeMetadata(siteName?: string, siteDescription?: string, siteUrl?: string, pagination?: {
41
73
  currentPage: number;
42
74
  totalPages: number;
43
- }): {
75
+ }, basePath?: string): {
44
76
  title: string;
45
77
  description: string;
46
78
  openGraph: {
@@ -81,13 +113,28 @@ interface ArticlePageProps {
81
113
  title: string;
82
114
  };
83
115
  };
116
+ /** Public path where this blog is mounted, e.g. "/blog" or "/new-blog". */
117
+ basePath?: string;
118
+ /** Optional theme values for host-site brand integration. */
119
+ theme?: BlogTheme;
120
+ /** Optional post-article CTA supplied by the host site. */
121
+ postArticleCta?: {
122
+ title: string;
123
+ description?: string;
124
+ href: string;
125
+ label: string;
126
+ };
127
+ /** Optional related articles supplied by the host site. */
128
+ relatedArticles?: PublishedArticle[];
129
+ /** Whether to render static article share links. */
130
+ showShareLinks?: boolean;
84
131
  }
85
- declare function ArticlePage({ article, className, navigation, }: ArticlePageProps): react_jsx_runtime.JSX.Element;
132
+ declare function ArticlePage({ article, className, navigation, basePath, theme, postArticleCta, relatedArticles, showShareLinks, }: ArticlePageProps): react_jsx_runtime.JSX.Element;
86
133
  /**
87
134
  * Generate metadata for the article page for SEO optimization.
88
135
  * This function should be used in the Next.js metadata API.
89
136
  */
90
- declare function generateArticleMetadata(article: PublishedArticle): {
137
+ declare function generateArticleMetadata(article: PublishedArticle, basePath?: string): {
91
138
  title: string;
92
139
  description: string;
93
140
  keywords: string;
@@ -202,6 +249,13 @@ declare function PaginationEllipsis({ className, ...props }: React.ComponentProp
202
249
 
203
250
  declare function cn(...inputs: ClassValue[]): string;
204
251
 
252
+ /**
253
+ * URL helpers shared by package UI, metadata, and sitemap integrations.
254
+ */
255
+ declare function normalizeBlogBasePath(basePath?: string): string;
256
+ declare function buildBlogPath(basePath: string | undefined, slug?: string): string;
257
+ declare function getPathPrefixFromBlogUrl(blogUrl: string): string;
258
+
205
259
  /**
206
260
  * Authentication configuration interface
207
261
  * Customers can implement this to customize authentication behavior
@@ -1796,4 +1850,4 @@ declare function OPTIONS(request: NextRequest): Promise<NextResponse>;
1796
1850
 
1797
1851
  declare const PACKAGE_VERSION: string;
1798
1852
 
1799
- export { ApiKeyAuth, type AuthConfig, type AuthResult, ArticlePage as BlogArticlePage, BlogHomePage, type BlogPlatformConfig, type BlogPlatformStorage, type BlogPostingSchema, type BlogSitemapConfig, type BreadcrumbListSchema, Button, type CanonicalUrlOptions, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, DrizzleStorage, EnvAuth, type GeneratedMetadata, InMemoryStorage, type LinkTag, type MetaTag, type MetadataOptions, type NextjsSitemapEntry, NoAuth, type OrganizationSchema, PACKAGE_VERSION, Pagination$1 as Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, type PersonSchema, PublishResult, PublishedArticle, PublishedAuthor, PublishedSite, type RateLimitConfig, type RateLimitResult, Pagination as ShadcnPagination, type SitemapChangeFreq, type SitemapData, type SitemapEntry, type SitemapOptions, StructuredDataError, type StructuredDataOptions, UninitializedAuth, type WebSiteSchema, autoConfigureRateLimit, bpArticles, bpOperations, buttonVariants, checkRateLimit, cn, configureRateLimit, createBlogSitemapRoute, createDynamicBlogSitemap, createRateLimitErrorResponse, createStructuredDataScript, enforceRateLimit, extractKeywordsFromArticle, extractTokenFromHeader, generateArticleMetadata, generateArticleStructuredData, generateAuthorStructuredData, generateBlogHomeMetadata, generateBlogHomeStructuredData, generateBlogSitemapEntries, generateBreadcrumbStructuredData, generateCanonicalUrl, generateCanonicalUrlFromSlug, generateCompleteArticleStructuredData, generateOrganizationStructuredData, generatePaginationMetadata, generateSiteMetadata, generateSitemap, generateSitemapIndex, generateWebSiteStructuredData, getAuthConfig, getBaseUrl, getDrizzleAdapterSql, getRateLimitHeaders, getStorage, initBlogPlatform, initBlogPlatformDev, initBlogPlatformOnce, initBlogPlatformProd, initEnvAuth, isValidCanonicalUrl, metadataToHtml, normalizeDomain, normalizeSlug, POST$1 as publishHandler, safeGenerateArticleStructuredData, setAuthConfig, setStorage, shouldSkipAuth, sitemapToXml, GET as slugExistsHandler, OPTIONS as slugExistsOptionsHandler, structuredDataToJsonLd, POST as unpublishHandler, updateArticleCanonicalUrl, usePagination, validateMetadata, validateSitemap, validateStructuredData, GET$1 as versionHandler };
1853
+ export { ApiKeyAuth, type AuthConfig, type AuthResult, ArticlePage as BlogArticlePage, BlogHomePage, type BlogPlatformConfig, type BlogPlatformStorage, type BlogPostingSchema, type BlogSitemapConfig, type BlogTheme, type BreadcrumbListSchema, Button, type CanonicalUrlOptions, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, DrizzleStorage, EnvAuth, type GeneratedMetadata, InMemoryStorage, type LinkTag, type MetaTag, type MetadataOptions, type NextjsSitemapEntry, NoAuth, type OrganizationSchema, PACKAGE_VERSION, Pagination$1 as Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, type PersonSchema, PublishResult, PublishedArticle, PublishedAuthor, PublishedSite, type RateLimitConfig, type RateLimitResult, Pagination as ShadcnPagination, type SitemapChangeFreq, type SitemapData, type SitemapEntry, type SitemapOptions, StructuredDataError, type StructuredDataOptions, UninitializedAuth, type WebSiteSchema, autoConfigureRateLimit, bpArticles, bpOperations, buildBlogPath, buttonVariants, checkRateLimit, cn, configureRateLimit, createBlogSitemapRoute, createDynamicBlogSitemap, createRateLimitErrorResponse, createStructuredDataScript, enforceRateLimit, extractKeywordsFromArticle, extractTableOfContents, extractTokenFromHeader, formatArticleDateMeta, generateArticleMetadata, generateArticleStructuredData, generateAuthorStructuredData, generateBlogHomeMetadata, generateBlogHomeStructuredData, generateBlogSitemapEntries, generateBreadcrumbStructuredData, generateCanonicalUrl, generateCanonicalUrlFromSlug, generateCompleteArticleStructuredData, generateOrganizationStructuredData, generatePaginationMetadata, generateSiteMetadata, generateSitemap, generateSitemapIndex, generateWebSiteStructuredData, getAuthConfig, getBaseUrl, getBlogThemeStyle, getDrizzleAdapterSql, getPathPrefixFromBlogUrl, getRateLimitHeaders, getStorage, initBlogPlatform, initBlogPlatformDev, initBlogPlatformOnce, initBlogPlatformProd, initEnvAuth, isValidCanonicalUrl, metadataToHtml, normalizeBlogBasePath, normalizeDomain, normalizeSlug, POST$1 as publishHandler, safeGenerateArticleStructuredData, setAuthConfig, setStorage, shouldSkipAuth, sitemapToXml, GET as slugExistsHandler, OPTIONS as slugExistsOptionsHandler, structuredDataToJsonLd, POST as unpublishHandler, updateArticleCanonicalUrl, usePagination, validateMetadata, validateSitemap, validateStructuredData, GET$1 as versionHandler };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,42 @@
1
1
  import { PublishedArticle, PublishedSite, PublishResult, PublishedAuthor } from './types/index.js';
2
2
  export { PublishPayload } from './types/index.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import * as class_variance_authority_types from 'class-variance-authority/types';
5
4
  import * as React from 'react';
5
+ import { CSSProperties } from 'react';
6
+ import * as class_variance_authority_types from 'class-variance-authority/types';
6
7
  import { VariantProps } from 'class-variance-authority';
7
8
  import { ClassValue } from 'clsx';
8
9
  import { NextRequest, NextResponse } from 'next/server';
9
10
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
10
11
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
11
12
 
13
+ interface BlogTheme {
14
+ accentColor?: string;
15
+ accentHoverColor?: string;
16
+ accentBackgroundColor?: string;
17
+ accentBorderColor?: string;
18
+ }
19
+ interface TocItem {
20
+ id: string;
21
+ text: string;
22
+ level: 2 | 3;
23
+ }
24
+ interface ArticleDateMeta {
25
+ publishedDateLabel: string;
26
+ publishedRelativeLabel: string;
27
+ updatedDateLabel: string;
28
+ isUpdated: boolean;
29
+ }
30
+ type BlogThemeStyle = CSSProperties & {
31
+ "--blog-accent": string;
32
+ "--blog-accent-hover": string;
33
+ "--blog-accent-bg": string;
34
+ "--blog-accent-border": string;
35
+ };
36
+ declare function getBlogThemeStyle(theme?: BlogTheme): BlogThemeStyle;
37
+ declare function formatArticleDateMeta(publishedAt: string, updatedAt: string): ArticleDateMeta;
38
+ declare function extractTableOfContents(markdown: string): TocItem[];
39
+
12
40
  interface BlogHomePageProps {
13
41
  articles: PublishedArticle[];
14
42
  siteName?: string;
@@ -18,12 +46,16 @@ interface BlogHomePageProps {
18
46
  site?: PublishedSite;
19
47
  /** Whether to include structured data */
20
48
  includeStructuredData?: boolean;
49
+ /** Public path where this blog is mounted, e.g. "/blog" or "/new-blog". */
50
+ basePath?: string;
21
51
  /** Pagination configuration */
22
52
  pagination?: {
23
53
  currentPage: number;
24
54
  totalPages: number;
25
55
  baseUrl?: string;
26
56
  };
57
+ /** Optional theme values for host-site brand integration. */
58
+ theme?: BlogTheme;
27
59
  }
28
60
  /**
29
61
  * Blog home page component that displays a list of published articles.
@@ -32,7 +64,7 @@ interface BlogHomePageProps {
32
64
  * @xexr/blog-platform package. It provides a clean, SEO-friendly
33
65
  * article listing with proper metadata.
34
66
  */
35
- declare function BlogHomePage({ articles, siteName, siteTagline, className, site, includeStructuredData, pagination, }: BlogHomePageProps): react_jsx_runtime.JSX.Element;
67
+ declare function BlogHomePage({ articles, siteName, siteTagline, className, site, includeStructuredData, basePath, pagination, theme, }: BlogHomePageProps): react_jsx_runtime.JSX.Element;
36
68
  /**
37
69
  * Generate metadata for the blog home page for SEO optimization.
38
70
  * This function should be used in the Next.js metadata API.
@@ -40,7 +72,7 @@ declare function BlogHomePage({ articles, siteName, siteTagline, className, site
40
72
  declare function generateBlogHomeMetadata(siteName?: string, siteDescription?: string, siteUrl?: string, pagination?: {
41
73
  currentPage: number;
42
74
  totalPages: number;
43
- }): {
75
+ }, basePath?: string): {
44
76
  title: string;
45
77
  description: string;
46
78
  openGraph: {
@@ -81,13 +113,28 @@ interface ArticlePageProps {
81
113
  title: string;
82
114
  };
83
115
  };
116
+ /** Public path where this blog is mounted, e.g. "/blog" or "/new-blog". */
117
+ basePath?: string;
118
+ /** Optional theme values for host-site brand integration. */
119
+ theme?: BlogTheme;
120
+ /** Optional post-article CTA supplied by the host site. */
121
+ postArticleCta?: {
122
+ title: string;
123
+ description?: string;
124
+ href: string;
125
+ label: string;
126
+ };
127
+ /** Optional related articles supplied by the host site. */
128
+ relatedArticles?: PublishedArticle[];
129
+ /** Whether to render static article share links. */
130
+ showShareLinks?: boolean;
84
131
  }
85
- declare function ArticlePage({ article, className, navigation, }: ArticlePageProps): react_jsx_runtime.JSX.Element;
132
+ declare function ArticlePage({ article, className, navigation, basePath, theme, postArticleCta, relatedArticles, showShareLinks, }: ArticlePageProps): react_jsx_runtime.JSX.Element;
86
133
  /**
87
134
  * Generate metadata for the article page for SEO optimization.
88
135
  * This function should be used in the Next.js metadata API.
89
136
  */
90
- declare function generateArticleMetadata(article: PublishedArticle): {
137
+ declare function generateArticleMetadata(article: PublishedArticle, basePath?: string): {
91
138
  title: string;
92
139
  description: string;
93
140
  keywords: string;
@@ -202,6 +249,13 @@ declare function PaginationEllipsis({ className, ...props }: React.ComponentProp
202
249
 
203
250
  declare function cn(...inputs: ClassValue[]): string;
204
251
 
252
+ /**
253
+ * URL helpers shared by package UI, metadata, and sitemap integrations.
254
+ */
255
+ declare function normalizeBlogBasePath(basePath?: string): string;
256
+ declare function buildBlogPath(basePath: string | undefined, slug?: string): string;
257
+ declare function getPathPrefixFromBlogUrl(blogUrl: string): string;
258
+
205
259
  /**
206
260
  * Authentication configuration interface
207
261
  * Customers can implement this to customize authentication behavior
@@ -1796,4 +1850,4 @@ declare function OPTIONS(request: NextRequest): Promise<NextResponse>;
1796
1850
 
1797
1851
  declare const PACKAGE_VERSION: string;
1798
1852
 
1799
- export { ApiKeyAuth, type AuthConfig, type AuthResult, ArticlePage as BlogArticlePage, BlogHomePage, type BlogPlatformConfig, type BlogPlatformStorage, type BlogPostingSchema, type BlogSitemapConfig, type BreadcrumbListSchema, Button, type CanonicalUrlOptions, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, DrizzleStorage, EnvAuth, type GeneratedMetadata, InMemoryStorage, type LinkTag, type MetaTag, type MetadataOptions, type NextjsSitemapEntry, NoAuth, type OrganizationSchema, PACKAGE_VERSION, Pagination$1 as Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, type PersonSchema, PublishResult, PublishedArticle, PublishedAuthor, PublishedSite, type RateLimitConfig, type RateLimitResult, Pagination as ShadcnPagination, type SitemapChangeFreq, type SitemapData, type SitemapEntry, type SitemapOptions, StructuredDataError, type StructuredDataOptions, UninitializedAuth, type WebSiteSchema, autoConfigureRateLimit, bpArticles, bpOperations, buttonVariants, checkRateLimit, cn, configureRateLimit, createBlogSitemapRoute, createDynamicBlogSitemap, createRateLimitErrorResponse, createStructuredDataScript, enforceRateLimit, extractKeywordsFromArticle, extractTokenFromHeader, generateArticleMetadata, generateArticleStructuredData, generateAuthorStructuredData, generateBlogHomeMetadata, generateBlogHomeStructuredData, generateBlogSitemapEntries, generateBreadcrumbStructuredData, generateCanonicalUrl, generateCanonicalUrlFromSlug, generateCompleteArticleStructuredData, generateOrganizationStructuredData, generatePaginationMetadata, generateSiteMetadata, generateSitemap, generateSitemapIndex, generateWebSiteStructuredData, getAuthConfig, getBaseUrl, getDrizzleAdapterSql, getRateLimitHeaders, getStorage, initBlogPlatform, initBlogPlatformDev, initBlogPlatformOnce, initBlogPlatformProd, initEnvAuth, isValidCanonicalUrl, metadataToHtml, normalizeDomain, normalizeSlug, POST$1 as publishHandler, safeGenerateArticleStructuredData, setAuthConfig, setStorage, shouldSkipAuth, sitemapToXml, GET as slugExistsHandler, OPTIONS as slugExistsOptionsHandler, structuredDataToJsonLd, POST as unpublishHandler, updateArticleCanonicalUrl, usePagination, validateMetadata, validateSitemap, validateStructuredData, GET$1 as versionHandler };
1853
+ export { ApiKeyAuth, type AuthConfig, type AuthResult, ArticlePage as BlogArticlePage, BlogHomePage, type BlogPlatformConfig, type BlogPlatformStorage, type BlogPostingSchema, type BlogSitemapConfig, type BlogTheme, type BreadcrumbListSchema, Button, type CanonicalUrlOptions, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, DrizzleStorage, EnvAuth, type GeneratedMetadata, InMemoryStorage, type LinkTag, type MetaTag, type MetadataOptions, type NextjsSitemapEntry, NoAuth, type OrganizationSchema, PACKAGE_VERSION, Pagination$1 as Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, type PersonSchema, PublishResult, PublishedArticle, PublishedAuthor, PublishedSite, type RateLimitConfig, type RateLimitResult, Pagination as ShadcnPagination, type SitemapChangeFreq, type SitemapData, type SitemapEntry, type SitemapOptions, StructuredDataError, type StructuredDataOptions, UninitializedAuth, type WebSiteSchema, autoConfigureRateLimit, bpArticles, bpOperations, buildBlogPath, buttonVariants, checkRateLimit, cn, configureRateLimit, createBlogSitemapRoute, createDynamicBlogSitemap, createRateLimitErrorResponse, createStructuredDataScript, enforceRateLimit, extractKeywordsFromArticle, extractTableOfContents, extractTokenFromHeader, formatArticleDateMeta, generateArticleMetadata, generateArticleStructuredData, generateAuthorStructuredData, generateBlogHomeMetadata, generateBlogHomeStructuredData, generateBlogSitemapEntries, generateBreadcrumbStructuredData, generateCanonicalUrl, generateCanonicalUrlFromSlug, generateCompleteArticleStructuredData, generateOrganizationStructuredData, generatePaginationMetadata, generateSiteMetadata, generateSitemap, generateSitemapIndex, generateWebSiteStructuredData, getAuthConfig, getBaseUrl, getBlogThemeStyle, getDrizzleAdapterSql, getPathPrefixFromBlogUrl, getRateLimitHeaders, getStorage, initBlogPlatform, initBlogPlatformDev, initBlogPlatformOnce, initBlogPlatformProd, initEnvAuth, isValidCanonicalUrl, metadataToHtml, normalizeBlogBasePath, normalizeDomain, normalizeSlug, POST$1 as publishHandler, safeGenerateArticleStructuredData, setAuthConfig, setStorage, shouldSkipAuth, sitemapToXml, GET as slugExistsHandler, OPTIONS as slugExistsOptionsHandler, structuredDataToJsonLd, POST as unpublishHandler, updateArticleCanonicalUrl, usePagination, validateMetadata, validateSitemap, validateStructuredData, GET$1 as versionHandler };