The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(transformer): find last modified date form commit on submodule (#1831)

* fix(transformer): find last modified date form commit on submodule

when the content folder has a submodule git, the relative path start in content folder and not root folder of quartz

* fix(transformer): use path.relative for improved path handling in last modified date calculation

* fix(transformer): keep find file from relative path of repo workdir

* fix(transformer): use variable for repository workdir

use default value if repo.workdir is undefined to user fullFp value

authored by

dralagen and committed by
GitHub
bcde2abc 25979ab2

+5 -1
+5 -1
quartz/plugins/transformers/lastmod.ts
··· 2 2 import { Repository } from "@napi-rs/simple-git" 3 3 import { QuartzTransformerPlugin } from "../types" 4 4 import chalk from "chalk" 5 + import path from "path" 5 6 6 7 export interface Options { 7 8 priority: ("frontmatter" | "git" | "filesystem")[] ··· 34 35 return [ 35 36 () => { 36 37 let repo: Repository | undefined = undefined 38 + let repositoryWorkdir: string 37 39 if (opts.priority.includes("git")) { 38 40 try { 39 41 repo = Repository.discover(ctx.argv.directory) 42 + repositoryWorkdir = repo.workdir() ?? "" 40 43 } catch (e) { 41 44 console.log( 42 45 chalk.yellow(`\nWarning: couldn't find git repository for ${ctx.argv.directory}`), ··· 62 65 published ||= file.data.frontmatter.published as MaybeDate 63 66 } else if (source === "git" && repo) { 64 67 try { 65 - modified ||= await repo.getFileLatestModifiedDateAsync(fullFp) 68 + const relativePath = path.relative(repositoryWorkdir, fullFp) 69 + modified ||= await repo.getFileLatestModifiedDateAsync(relativePath) 66 70 } catch { 67 71 console.log( 68 72 chalk.yellow(