Skip to content

Commit

Permalink
feat: allow custom edge renderer when writing file to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 5, 2024
1 parent 93c4036 commit bafe64e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/collection/collection_entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file that was distributed with this source code.
*/

import type { Edge } from 'edge.js'
import { dirname, join } from 'node:path'
import type { MarkdownFile } from '@dimerapp/markdown'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
Expand Down Expand Up @@ -106,12 +107,17 @@ export class CollectionEntry extends BaseEntry {
/**
* Writes the collection entry HTML to the disk
*/
async writeToDisk(outputDir: string, state?: Record<string, any>, filePath?: string) {
async writeToDisk(
outputDir: string,
state?: Record<string, any>,
filePath?: string,
edgeRenderer?: ReturnType<Edge['createRenderer']>
) {
filePath = filePath || `${this.#permalinkToFilePath(this.permalink)}.html`
const outputPath = join(outputDir, filePath)

await mkdir(dirname(outputPath), { recursive: true })
await writeFile(outputPath, await this.render(state))
await writeFile(outputPath, await this.render(state, edgeRenderer))

return {
outputDir,
Expand Down

0 comments on commit bafe64e

Please sign in to comment.