@riebeckite/core 0.0.10 → 0.0.12

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.ts CHANGED
@@ -47,7 +47,7 @@ export type { PluginDiagnostic, PluginDiagnosticLevel, } from "./src/types/plugi
47
47
  export type { PluginEndpoint, PluginEndpointContext, PluginEndpointMethod, PluginEndpointOptions, PluginEndpointRequest, PluginEndpointResponse, } from "./src/types/plugin_endpoint.js";
48
48
  export { defineEndpoint } from "./src/types/plugin_endpoint.js";
49
49
  export type { PluginHeadTag } from "./src/types/plugin_head.js";
50
- export type { HtmlPipeline, MarkdownEmbedFragment, MarkdownPipeline, MarkdownPipelineContext, PipelinePlugin, } from "./src/types/plugin_pipeline.js";
50
+ export type { HtmlPipeline, MarkdownEmbedFragment, MarkdownExecutionContext, MarkdownPipeline, MarkdownPipelineContext, PipelinePlugin, } from "./src/types/plugin_pipeline.js";
51
51
  export type { PluginSeoExtension, RenderableFeedEntry, SeoMetadata, WebsiteSeoInput, } from "./src/types/plugin_seo.js";
52
52
  export type { PostContent, PostFrontmatter } from "./src/types/post_content.js";
53
53
  export type { PublishFrontmatter, PublishStrategy, } from "./src/types/publish_strategy.js";
package/dist/index.js CHANGED
@@ -1546,7 +1546,15 @@ var Pipeline = class {
1546
1546
  options;
1547
1547
  isBuildTime;
1548
1548
  pluginCaches = /* @__PURE__ */ new Map();
1549
- async execute(markDownContent, embedDepth = 0, embedTrail = /* @__PURE__ */ new Set()) {
1549
+ async execute(markDownContent, context = {}) {
1550
+ return await this.executeWithEmbedState(
1551
+ markDownContent,
1552
+ context,
1553
+ 0,
1554
+ new Set(context.sourceSlug ? [context.sourceSlug] : [])
1555
+ );
1556
+ }
1557
+ async executeWithEmbedState(markDownContent, context, embedDepth, embedTrail) {
1550
1558
  const processor = unified();
1551
1559
  const plugins = resolvePlugins(this.options.plugins);
1552
1560
  this.use(processor, remarkParse);
@@ -1560,6 +1568,7 @@ var Pipeline = class {
1560
1568
  this.use(processor, remarkMath);
1561
1569
  this.use(processor, remarkGfm);
1562
1570
  const markdownPipelineContext = {
1571
+ sourceSlug: context.sourceSlug,
1563
1572
  contentIndex: this.contentIndex,
1564
1573
  resolvePermalink: (slug) => this.getPermalink(slug),
1565
1574
  renderNoteEmbed: this.createNoteEmbedRenderer(embedDepth, embedTrail),
@@ -1625,8 +1634,9 @@ var Pipeline = class {
1625
1634
  if (!markdown) return null;
1626
1635
  const nextEmbedTrail = new Set(embedTrail);
1627
1636
  nextEmbedTrail.add(slug);
1628
- const content = await this.execute(
1637
+ const content = await this.executeWithEmbedState(
1629
1638
  markdown,
1639
+ { sourceSlug: slug },
1630
1640
  embedDepth + 1,
1631
1641
  nextEmbedTrail
1632
1642
  );
@@ -2783,11 +2793,9 @@ var ContentManager = class {
2783
2793
  this.pipelineOptions,
2784
2794
  this.isBuildTime
2785
2795
  );
2786
- const content = await this.pipeline.execute(
2787
- rawPost,
2788
- 0,
2789
- /* @__PURE__ */ new Set([slug])
2790
- );
2796
+ const content = await this.pipeline.execute(rawPost, {
2797
+ sourceSlug: slug
2798
+ });
2791
2799
  await this.pluginRuntime.runPostHook(
2792
2800
  "onPostParsed",
2793
2801
  slug,
@@ -1,6 +1,7 @@
1
1
  import type { ContentSource } from "./content/content_source.js";
2
2
  import type { Observability } from "./observability.js";
3
3
  import type { RiebeckitePlugin } from "./types/plugin.js";
4
+ import type { MarkdownExecutionContext } from "./types/plugin_pipeline.js";
4
5
  import type { PostContent } from "./types/post_content.js";
5
6
  export interface PipelineOptions {
6
7
  plugins?: RiebeckitePlugin[];
@@ -16,7 +17,8 @@ export declare class Pipeline {
16
17
  private isBuildTime;
17
18
  private pluginCaches;
18
19
  constructor(contentIndex: Map<string, string>, permalinks: ReadonlyMap<string, string>, getMarkdownBySlug?: (slug: string) => Promise<string>, options?: PipelineOptions, isBuildTime?: boolean);
19
- execute(markDownContent: string, embedDepth?: number, embedTrail?: Set<string>): Promise<PostContent>;
20
+ execute(markDownContent: string, context?: MarkdownExecutionContext): Promise<PostContent>;
21
+ private executeWithEmbedState;
20
22
  private getPermalink;
21
23
  private use;
22
24
  private createNoteEmbedRenderer;
@@ -6,7 +6,14 @@ export type MarkdownPipeline = {
6
6
  use(plugin: PipelinePlugin, options?: unknown): void;
7
7
  };
8
8
  export type HtmlPipeline = MarkdownPipeline;
9
+ /** Identifies the source being processed by a Markdown pipeline execution. */
10
+ export type MarkdownExecutionContext = {
11
+ /** Slug of the content currently being rendered, when available. */
12
+ sourceSlug?: string;
13
+ };
9
14
  export type MarkdownPipelineContext = {
15
+ /** Source identity supplied for this execution, when available. */
16
+ sourceSlug?: MarkdownExecutionContext["sourceSlug"];
10
17
  contentIndex: Map<string, string>;
11
18
  resolvePermalink: (slug: string) => string;
12
19
  renderNoteEmbed?: (slug: string, fragment: MarkdownEmbedFragment | null) => Promise<string | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/core",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsx": "^4.22.4",
46
- "@riebeckite/test": "0.0.10"
46
+ "@riebeckite/test": "0.0.12"
47
47
  },
48
48
  "repository": {
49
49
  "type": "git",