diff --git a/packages/contented-example/contented.config.js b/packages/contented-example/contented.config.js index bf0825fc..277209f3 100644 --- a/packages/contented-example/contented.config.js +++ b/packages/contented-example/contented.config.js @@ -25,6 +25,12 @@ const config = { tags: { type: 'string[]', }, + editOnGitHubLink: { + type: 'string', + resolve: (_, { file }) => { + return `https://github.com/levaintech/contented/edit/main/packages/contented-example/${file.data.contented.filePath}`; + }, + }, }, transform: (file) => { file.path = file.path.replaceAll(/^\/docs\/?/g, '/'); diff --git a/packages/contented-pipeline-md/src/MarkdownPipeline.ts b/packages/contented-pipeline-md/src/MarkdownPipeline.ts index 1224db14..1a9b79a5 100644 --- a/packages/contented-pipeline-md/src/MarkdownPipeline.ts +++ b/packages/contented-pipeline-md/src/MarkdownPipeline.ts @@ -26,7 +26,7 @@ export class MarkdownPipeline extends ContentedPipeline { return []; } - vFile.data = { contented: this.newUnifiedContented() }; + vFile.data = { contented: this.newUnifiedContented(file) }; const output = await this.processor.process(vFile); const contented = output.data.contented as UnifiedContented; @@ -44,13 +44,14 @@ export class MarkdownPipeline extends ContentedPipeline { return read(join(rootPath, file)); } - protected newUnifiedContented(): UnifiedContented { + protected newUnifiedContented(filePath: string): UnifiedContented { return { contentedPipeline: this, pipeline: this.pipeline, headings: [], fields: {}, errors: [], + filePath, }; } diff --git a/packages/contented-pipeline-md/src/plugins/Plugin.ts b/packages/contented-pipeline-md/src/plugins/Plugin.ts index b0f700d7..ccb1b994 100644 --- a/packages/contented-pipeline-md/src/plugins/Plugin.ts +++ b/packages/contented-pipeline-md/src/plugins/Plugin.ts @@ -12,4 +12,5 @@ export interface UnifiedContented { type: string; reason: string; }[]; + filePath: string; } diff --git a/packages/contented-preview/src/pages/[[...slug]].page.jsx b/packages/contented-preview/src/pages/[[...slug]].page.jsx index b580b9ea..a3fdd008 100644 --- a/packages/contented-preview/src/pages/[[...slug]].page.jsx +++ b/packages/contented-preview/src/pages/[[...slug]].page.jsx @@ -92,7 +92,7 @@ export default function SlugPage({ content, sections }) {