Skip to content

Instantly share code, notes, and snippets.

@FlynnOConnell
Created December 17, 2022 22:27
Show Gist options
  • Save FlynnOConnell/fc5c4df0640fbe029c0c1836403f3b65 to your computer and use it in GitHub Desktop.
Save FlynnOConnell/fc5c4df0640fbe029c0c1836403f3b65 to your computer and use it in GitHub Desktop.
<template>
<div class="blue-shadow">
<highlightjs :language="gistprops.language" :code="gistcontent" />
</div>
</template>
<script setup>
import highlightjs from '@/components/subcomponents/HighlightCode.vue';
import { onMounted, ref, computed } from 'vue';
import { Octokit } from 'octokit';
let gist = ref('');
let gistcontent = computed(() => gist.value);
const octokit = new Octokit({
auth: import.meta.env.VITE_GITHUB_TOKEN
})
const gistprops = defineProps({
gist_id: {
type: String,
required: true
},
file_name: {
type: String,
required: true
},
language: {
type: String,
required: true
},
});
onMounted(async () => {
let mygist = await octokit.request(`GET /gists/${gistprops.gist_id}`,
{
gist_id: gistprops.gist_id
}
)
gist.value = mygist.data.files[`${gistprops.file_name}`].content;
console.log('loaded')
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment