(notes) add routing between notes

This commit is contained in:
2021-03-13 22:11:58 +01:00
parent 2bb43ac961
commit 8fad931dfd
12 changed files with 343 additions and 65 deletions

30
src/hooks/useFile.hook.ts Normal file
View File

@@ -0,0 +1,30 @@
import { ref } from 'vue'
import { request } from '@octokit/request'
import { useMarkdown } from '@/hooks/useMarkdown.hook'
export const useFile = (owner: string, repo: string, sha: string) => {
const content = ref('')
const getContent = async () => {
const { render } = useMarkdown()
const file = await request(
'GET /repos/{owner}/{repo}/git/blobs/{file_sha}',
{
owner,
repo,
file_sha: sha
}
)
if (!file) {
return
}
content.value = render(file.data.content)
}
getContent()
return {
content
}
}