mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
fix(transformer): keep find file from relative path of repo workdir
This commit is contained in:
parent
025db83060
commit
baa9a49c8c
@ -2,6 +2,7 @@ import fs from "fs"
|
|||||||
import { Repository } from "@napi-rs/simple-git"
|
import { Repository } from "@napi-rs/simple-git"
|
||||||
import { QuartzTransformerPlugin } from "../types"
|
import { QuartzTransformerPlugin } from "../types"
|
||||||
import chalk from "chalk"
|
import chalk from "chalk"
|
||||||
|
import path from "path"
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
priority: ("frontmatter" | "git" | "filesystem")[]
|
priority: ("frontmatter" | "git" | "filesystem")[]
|
||||||
@ -60,15 +61,8 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
|
|||||||
created ||= file.data.frontmatter.created as MaybeDate
|
created ||= file.data.frontmatter.created as MaybeDate
|
||||||
modified ||= file.data.frontmatter.modified as MaybeDate
|
modified ||= file.data.frontmatter.modified as MaybeDate
|
||||||
published ||= file.data.frontmatter.published as MaybeDate
|
published ||= file.data.frontmatter.published as MaybeDate
|
||||||
} else if (source === "git") {
|
} else if (source === "git" && repo) {
|
||||||
if (!repo) {
|
|
||||||
// Get a reference to the main git repo.
|
|
||||||
// It's either the same as the workdir,
|
|
||||||
// or 1+ level higher in case of a submodule/subtree setup
|
|
||||||
repo = Repository.discover(fullFp)
|
|
||||||
}
|
|
||||||
const relativePath = path.relative(repo.workdir()!, fullFp)
|
const relativePath = path.relative(repo.workdir()!, fullFp)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
modified ||= await repo.getFileLatestModifiedDateAsync(relativePath)
|
modified ||= await repo.getFileLatestModifiedDateAsync(relativePath)
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user