Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getRelativeRepoPath for the case of vault-inside-repo #722

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tomoyanonymous
Copy link

@tomoyanonymous tomoyanonymous commented Apr 15, 2024

This fixes #660.

Currently, getRelativeRepoPath considers only the case of git repository is located inside the vault.
If the vault is inside a subdirectory of git repository (this is a common case when you are using a self-host publishing system like Quartz), line authoring feature won't work.

This code resolves the relative path between git repo and vault using path library.

if (this.plugin.settings.basePath.length > 0) {
return path.substring(this.plugin.settings.basePath.length + 1);
let adapter = this.plugin.app.vault.adapter;
if (adapter instanceof FileSystemAdapter) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On mobile, this method does nothing now. I think we should fall back to the old implementation on mobile.

import ObsidianGit from "../main";
import { relative, join } from 'path';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please import path with as path here to make the usage from the path library more clearly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean import * as path from 'path'; ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Line author fails when the vault is a subdir of the git repo
2 participants