✨ (notes) add routing between notes
This commit is contained in:
30
src/hooks/useFile.hook.ts
Normal file
30
src/hooks/useFile.hook.ts
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user