generated from tpl/obsidian-sample-plugin
24 lines
465 B
Svelte
24 lines
465 B
Svelte
<script lang="ts">
|
|
import { getLinkpath, TFile } from "obsidian";
|
|
import type { Snippet } from "svelte";
|
|
|
|
interface Props {
|
|
children?: Snippet;
|
|
file: TFile | string;
|
|
}
|
|
|
|
let { children, file }: Props = $props();
|
|
|
|
function makeUri(path: string) {
|
|
return `obsidian://open?file=${encodeURIComponent(path)}`;
|
|
}
|
|
|
|
const href = $derived(
|
|
makeUri(file instanceof TFile ? file.path : getLinkpath(file)),
|
|
);
|
|
</script>
|
|
|
|
<a {href}>
|
|
{@render children?.()}
|
|
</a>
|