Public Access
23 lines
823 B
C#
23 lines
823 B
C#
namespace MeetingAssistant.MeetingNotes;
|
|
|
|
public static class ObsidianLink
|
|
{
|
|
public static string ToWikiLink(string pathOrLink, string sourceNotePath, string label)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(pathOrLink) || pathOrLink.StartsWith("[[", StringComparison.Ordinal))
|
|
{
|
|
return pathOrLink;
|
|
}
|
|
|
|
var sourceFolder = Path.GetDirectoryName(sourceNotePath) ?? "";
|
|
var relativePath = Path.GetRelativePath(sourceFolder, pathOrLink);
|
|
var withoutExtension = Path.Combine(
|
|
Path.GetDirectoryName(relativePath) ?? "",
|
|
Path.GetFileNameWithoutExtension(relativePath))
|
|
.Replace(Path.DirectorySeparatorChar, '/')
|
|
.Replace(Path.AltDirectorySeparatorChar, '/');
|
|
|
|
return $"[[{withoutExtension}|{label}]]";
|
|
}
|
|
}
|