@analogjs/content 2.8.0-beta.1 → 2.8.0-beta.11
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/fesm2022/analogjs-content-og.mjs +31 -45
- package/fesm2022/analogjs-content-og.mjs.map +1 -1
- package/fesm2022/analogjs-content-prism-highlighter.mjs +75 -68
- package/fesm2022/analogjs-content-prism-highlighter.mjs.map +1 -1
- package/fesm2022/analogjs-content-resources.mjs +108 -145
- package/fesm2022/analogjs-content-resources.mjs.map +1 -1
- package/fesm2022/analogjs-content-shiki-highlighter.mjs +7 -14
- package/fesm2022/analogjs-content-shiki-highlighter.mjs.map +1 -1
- package/fesm2022/analogjs-content.mjs +747 -760
- package/fesm2022/analogjs-content.mjs.map +1 -1
- package/package.json +1 -1
- package/types/analogjs-content-og.d.ts +14 -18
- package/types/analogjs-content-prism-highlighter.d.ts +12 -13
- package/types/analogjs-content-resources.d.ts +5 -11
- package/types/analogjs-content-shiki-highlighter.d.ts +6 -10
- package/types/analogjs-content.d.ts +159 -152
|
@@ -1,169 +1,178 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { InjectionToken, Provider,
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<AnchorNavigationDirective, "[analogAnchorNavigation]", never, {}, {}, never, never, true, never>;
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { AbstractType, AfterViewChecked, InjectionToken, Provider, ProviderToken, Signal, Type } from "@angular/core";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import { SafeHtml } from "@angular/platform-browser";
|
|
5
|
+
import { marked } from "marked";
|
|
6
|
+
declare namespace anchor_navigation_directive_d_exports {
|
|
7
|
+
export { AnchorNavigationDirective };
|
|
8
|
+
}
|
|
9
|
+
export declare class AnchorNavigationDirective {
|
|
10
|
+
private readonly document;
|
|
11
|
+
private readonly location;
|
|
12
|
+
private readonly router;
|
|
13
|
+
handleNavigation(element: EventTarget | null): boolean;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AnchorNavigationDirective, never>;
|
|
15
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AnchorNavigationDirective, "[analogAnchorNavigation]", never, {}, {}, never, never, true, never>;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
type TableOfContentItem = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
id: string;
|
|
19
|
+
level: number;
|
|
20
|
+
text: string;
|
|
23
21
|
};
|
|
24
22
|
type RenderedContent = {
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
content: string;
|
|
24
|
+
toc: TableOfContentItem[];
|
|
27
25
|
};
|
|
28
|
-
declare abstract class ContentRenderer {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
export declare abstract class ContentRenderer {
|
|
27
|
+
render(content: string): Promise<RenderedContent>;
|
|
28
|
+
getContentHeadings(_content: string): TableOfContentItem[];
|
|
29
|
+
enhance(): void;
|
|
30
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ContentRenderer, never>;
|
|
31
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
34
32
|
}
|
|
35
|
-
declare class NoopContentRenderer implements ContentRenderer {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
export declare class NoopContentRenderer implements ContentRenderer {
|
|
34
|
+
private readonly transferState;
|
|
35
|
+
private contentId;
|
|
36
|
+
/**
|
|
37
|
+
* Generates a hash from the content string
|
|
38
|
+
* to be used with the transfer state
|
|
39
|
+
*/
|
|
40
|
+
private generateHash;
|
|
41
|
+
render(content: string): Promise<RenderedContent>;
|
|
42
|
+
enhance(): void;
|
|
43
|
+
getContentHeadings(content: string): TableOfContentItem[];
|
|
44
|
+
private extractHeadings;
|
|
45
|
+
private extractHeadingsFromMarkdown;
|
|
46
|
+
private extractHeadingsFromHtml;
|
|
47
|
+
private makeSlug;
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
toc?: TableOfContentItem[];
|
|
49
|
+
export interface ContentFile<Attributes extends Record<string, any> = Record<string, any>> {
|
|
50
|
+
filename: string;
|
|
51
|
+
slug: string;
|
|
52
|
+
content?: string | object;
|
|
53
|
+
attributes: Attributes;
|
|
54
|
+
toc?: TableOfContentItem[];
|
|
58
55
|
}
|
|
59
|
-
|
|
60
56
|
/**
|
|
61
57
|
* Retrieves the static content using the provided param and/or prefix.
|
|
62
58
|
*
|
|
63
59
|
* @param param route parameter (default: 'slug')
|
|
64
60
|
* @param fallback fallback text if content file is not found (default: 'No Content Found')
|
|
65
61
|
*/
|
|
66
|
-
declare function injectContent<Attributes extends Record<string, any> = Record<string, any>>(param?: string | {
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
export declare function injectContent<Attributes extends Record<string, any> = Record<string, any>>(param?: string | {
|
|
63
|
+
param: string;
|
|
64
|
+
subdirectory: string;
|
|
69
65
|
} | {
|
|
70
|
-
|
|
66
|
+
customFilename: string;
|
|
71
67
|
}, fallback?: string): Observable<ContentFile<Attributes | Record<string, never>>>;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
declare
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownContentRendererService, never>;
|
|
83
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<MarkdownContentRendererService>;
|
|
68
|
+
export declare function injectContentFiles<Attributes extends Record<string, any>>(filterFn?: InjectContentFilesFilterFunction<Attributes>): ContentFile<Attributes>[];
|
|
69
|
+
export type InjectContentFilesFilterFunction<T extends Record<string, any>> = (value: ContentFile<T>, index: number, array: ContentFile<T>[]) => boolean;
|
|
70
|
+
export declare function injectContentFilesMap(): Record<string, () => Promise<string>>;
|
|
71
|
+
export declare class MarkdownContentRendererService implements ContentRenderer {
|
|
72
|
+
#private;
|
|
73
|
+
render(content: string): Promise<RenderedContent>;
|
|
74
|
+
getContentHeadings(content: string): TableOfContentItem[];
|
|
75
|
+
enhance(): void;
|
|
76
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownContentRendererService, never>;
|
|
77
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
84
78
|
}
|
|
85
|
-
|
|
86
79
|
interface MarkdownRendererOptions {
|
|
87
|
-
|
|
80
|
+
loadMermaid?: () => Promise<typeof import('mermaid')>;
|
|
88
81
|
}
|
|
89
|
-
declare function withMarkdownRenderer(options?: MarkdownRendererOptions): Provider;
|
|
90
|
-
declare function provideContent(...features: Provider[]): Provider[];
|
|
91
|
-
declare const MERMAID_IMPORT_TOKEN: InjectionToken<Promise<typeof mermaid>>;
|
|
92
|
-
|
|
82
|
+
export declare function withMarkdownRenderer(options?: MarkdownRendererOptions): Provider;
|
|
83
|
+
export declare function provideContent(...features: Provider[]): Provider[];
|
|
84
|
+
export declare const MERMAID_IMPORT_TOKEN: InjectionToken<Promise<typeof import("mermaid")>>;
|
|
93
85
|
declare class AnalogMarkdownRouteComponent implements AfterViewChecked {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
private sanitizer;
|
|
87
|
+
private route;
|
|
88
|
+
contentRenderer: ContentRenderer;
|
|
89
|
+
protected content: SafeHtml;
|
|
90
|
+
classes: string;
|
|
91
|
+
ngAfterViewChecked(): void;
|
|
92
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AnalogMarkdownRouteComponent, never>;
|
|
93
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AnalogMarkdownRouteComponent, "analog-markdown-route", never, {
|
|
94
|
+
"classes": {
|
|
95
|
+
"alias": "classes";
|
|
96
|
+
"required": false;
|
|
97
|
+
};
|
|
98
|
+
}, {}, never, never, true, [{
|
|
99
|
+
directive: typeof AnchorNavigationDirective;
|
|
100
|
+
inputs: {};
|
|
101
|
+
outputs: {};
|
|
102
|
+
}]>;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
104
|
declare class AnalogMarkdownComponent implements AfterViewChecked {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
105
|
+
private sanitizer;
|
|
106
|
+
private route;
|
|
107
|
+
private zone;
|
|
108
|
+
private readonly platformId;
|
|
109
|
+
private readonly mermaidImport;
|
|
110
|
+
private mermaid;
|
|
111
|
+
private contentSource;
|
|
112
|
+
readonly htmlContent: Signal<SafeHtml | undefined>;
|
|
113
|
+
readonly content: import("@angular/core").InputSignal<string | object | null | undefined>;
|
|
114
|
+
readonly classes: import("@angular/core").InputSignal<string>;
|
|
115
|
+
contentRenderer: ContentRenderer;
|
|
116
|
+
constructor();
|
|
117
|
+
getContentSource(): import("rxjs").Observable<string | SafeHtml>;
|
|
118
|
+
renderContent(content: string): Promise<string>;
|
|
119
|
+
ngAfterViewChecked(): void;
|
|
120
|
+
private loadMermaid;
|
|
121
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AnalogMarkdownComponent, never>;
|
|
122
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AnalogMarkdownComponent, "analog-markdown", never, {
|
|
123
|
+
"content": {
|
|
124
|
+
"alias": "content";
|
|
125
|
+
"required": false;
|
|
126
|
+
"isSignal": true;
|
|
127
|
+
};
|
|
128
|
+
"classes": {
|
|
129
|
+
"alias": "classes";
|
|
130
|
+
"required": false;
|
|
131
|
+
"isSignal": true;
|
|
132
|
+
};
|
|
133
|
+
}, {}, never, never, true, [{
|
|
134
|
+
directive: typeof AnchorNavigationDirective;
|
|
135
|
+
inputs: {};
|
|
136
|
+
outputs: {};
|
|
137
|
+
}]>;
|
|
123
138
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
attributes: Attributes;
|
|
139
|
+
export declare function parseRawContentFile<Attributes extends Record<string, any>>(rawContentFile: string): {
|
|
140
|
+
content: string;
|
|
141
|
+
attributes: Attributes;
|
|
128
142
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<MarkedSetupService>;
|
|
143
|
+
export declare class MarkedSetupService {
|
|
144
|
+
private readonly marked;
|
|
145
|
+
private readonly highlighter;
|
|
146
|
+
constructor();
|
|
147
|
+
getMarkedInstance(): typeof marked;
|
|
148
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MarkedSetupService, never>;
|
|
149
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
137
150
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
augmentCodeBlock?(code: string, lang: string): string;
|
|
151
|
+
export interface MarkedContentHighlighter {
|
|
152
|
+
augmentCodeBlock?(code: string, lang: string): string;
|
|
141
153
|
}
|
|
142
|
-
declare abstract class MarkedContentHighlighter {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
154
|
+
export declare abstract class MarkedContentHighlighter {
|
|
155
|
+
abstract getHighlightExtension(): import('marked').MarkedExtension;
|
|
156
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MarkedContentHighlighter, never>;
|
|
157
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
146
158
|
}
|
|
147
|
-
declare function withHighlighter(provider: ({
|
|
148
|
-
|
|
159
|
+
export declare function withHighlighter(provider: ({
|
|
160
|
+
useValue: MarkedContentHighlighter;
|
|
149
161
|
} | {
|
|
150
|
-
|
|
162
|
+
useClass: Type<MarkedContentHighlighter> | AbstractType<MarkedContentHighlighter>;
|
|
151
163
|
} | {
|
|
152
|
-
|
|
164
|
+
useFactory: (...deps: any[]) => MarkedContentHighlighter;
|
|
153
165
|
}) & {
|
|
154
|
-
|
|
166
|
+
deps?: ProviderToken<any>[];
|
|
155
167
|
}): Provider;
|
|
156
|
-
|
|
157
168
|
type ContentListLoaderFunction<Attributes extends Record<string, any>> = () => Promise<ContentFile<Attributes>[]>;
|
|
158
|
-
declare const CONTENT_LIST_LOADER: InjectionToken<ContentListLoaderFunction<any>>;
|
|
159
|
-
declare function injectContentListLoader<Attributes extends Record<string, any>>(): ContentListLoaderFunction<Attributes>;
|
|
160
|
-
declare function withContentListLoader(): Provider;
|
|
161
|
-
|
|
169
|
+
export declare const CONTENT_LIST_LOADER: InjectionToken<ContentListLoaderFunction<any>>;
|
|
170
|
+
export declare function injectContentListLoader<Attributes extends Record<string, any>>(): ContentListLoaderFunction<Attributes>;
|
|
171
|
+
export declare function withContentListLoader(): Provider;
|
|
162
172
|
type ContentFileLoaderFunction = () => Promise<Record<string, () => Promise<string>>>;
|
|
163
|
-
declare const CONTENT_FILE_LOADER: InjectionToken<ContentFileLoaderFunction>;
|
|
164
|
-
declare function injectContentFileLoader(): ContentFileLoaderFunction;
|
|
165
|
-
declare function withContentFileLoader(): Provider;
|
|
166
|
-
|
|
173
|
+
export declare const CONTENT_FILE_LOADER: InjectionToken<ContentFileLoaderFunction>;
|
|
174
|
+
export declare function injectContentFileLoader(): ContentFileLoaderFunction;
|
|
175
|
+
export declare function withContentFileLoader(): Provider;
|
|
167
176
|
/**
|
|
168
177
|
* Token for the active content locale.
|
|
169
178
|
* Provided via `withLocale()` in `provideContent()`.
|
|
@@ -171,23 +180,23 @@ declare function withContentFileLoader(): Provider;
|
|
|
171
180
|
* When set, `injectContentFiles()` filters to content matching this locale,
|
|
172
181
|
* and `injectContent()` resolves locale-prefixed content paths first.
|
|
173
182
|
*/
|
|
174
|
-
declare const CONTENT_LOCALE: InjectionToken<string>;
|
|
183
|
+
export declare const CONTENT_LOCALE: InjectionToken<string>;
|
|
175
184
|
/**
|
|
176
185
|
* Injects the content locale, returning null if not configured.
|
|
177
186
|
*/
|
|
178
|
-
declare function injectContentLocale(): string | null;
|
|
187
|
+
export declare function injectContentLocale(): string | null;
|
|
179
188
|
interface ContentLocaleOptions {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Function that returns the active locale.
|
|
191
|
+
* Runs in injection context so `inject()` can be used to read
|
|
192
|
+
* from other tokens (e.g., a LOCALE token from a router package).
|
|
193
|
+
*
|
|
194
|
+
* ```typescript
|
|
195
|
+
* withLocale({ loadLocale: injectLocale })
|
|
196
|
+
* withLocale({ loadLocale: () => navigator.language.split('-')[0] })
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
loadLocale: () => string | null;
|
|
191
200
|
}
|
|
192
201
|
/**
|
|
193
202
|
* Content feature that sets the active locale for content resolution.
|
|
@@ -213,7 +222,7 @@ interface ContentLocaleOptions {
|
|
|
213
222
|
* )
|
|
214
223
|
* ```
|
|
215
224
|
*/
|
|
216
|
-
declare function withLocale(locale: string | ContentLocaleOptions): Provider;
|
|
225
|
+
export declare function withLocale(locale: string | ContentLocaleOptions): Provider;
|
|
217
226
|
/**
|
|
218
227
|
* Filters content files by locale using map-based key lookup.
|
|
219
228
|
*
|
|
@@ -224,12 +233,10 @@ declare function withLocale(locale: string | ContentLocaleOptions): Provider;
|
|
|
224
233
|
*
|
|
225
234
|
* Files in a different locale's subdirectory are always excluded.
|
|
226
235
|
*/
|
|
227
|
-
declare function filterByLocale<T extends Record<string, any>>(files: ContentFile<T>[], locale: string): ContentFile<T>[];
|
|
236
|
+
export declare function filterByLocale<T extends Record<string, any>>(files: ContentFile<T>[], locale: string): ContentFile<T>[];
|
|
228
237
|
/**
|
|
229
238
|
* Prepends locale-prefixed candidates before the standard candidates
|
|
230
239
|
* for content file map key lookup.
|
|
231
240
|
*/
|
|
232
|
-
declare function withLocaleCandidates(candidates: string[], locale: string | null | undefined): string[];
|
|
233
|
-
|
|
234
|
-
export { AnchorNavigationDirective, CONTENT_FILE_LOADER, CONTENT_LIST_LOADER, CONTENT_LOCALE, ContentRenderer, MERMAID_IMPORT_TOKEN, AnalogMarkdownComponent as MarkdownComponent, MarkdownContentRendererService, AnalogMarkdownRouteComponent as MarkdownRouteComponent, MarkedContentHighlighter, MarkedSetupService, NoopContentRenderer, filterByLocale, injectContent, injectContentFileLoader, injectContentFiles, injectContentFilesMap, injectContentListLoader, injectContentLocale, parseRawContentFile, provideContent, withContentFileLoader, withContentListLoader, withHighlighter, withLocale, withLocaleCandidates, withMarkdownRenderer };
|
|
235
|
-
export type { ContentFile, InjectContentFilesFilterFunction };
|
|
241
|
+
export declare function withLocaleCandidates(candidates: string[], locale: string | null | undefined): string[];
|
|
242
|
+
export { AnalogMarkdownComponent as MarkdownComponent, AnalogMarkdownRouteComponent as MarkdownRouteComponent };
|