some progress. and prep to add new component
This commit is contained in:
parent
139875a99f
commit
1a9258463b
|
@ -2,26 +2,50 @@ import { defineIntegration, createResolver } from "astro-integration-kit"
|
|||
import { corePlugins } from "astro-integration-kit/plugins"
|
||||
import { astroGistsExpressiveCode } from "./integrations/expressive-code"
|
||||
|
||||
|
||||
/** Astro-Gist - Astro Integration
|
||||
* - There is currently no configuration for this integration. Just add it to your astro Integration list.
|
||||
* @example
|
||||
* import astroGist from "@matthiesenxyz/astro-gists";
|
||||
* export default defineConfig({
|
||||
* integrations: [astroGist()]
|
||||
* });
|
||||
*/
|
||||
export default defineIntegration({
|
||||
name: "@matthiesenxyz/astro-gists",
|
||||
plugins: [...corePlugins],
|
||||
setup() {
|
||||
const { resolve } = createResolver(import.meta.url);
|
||||
return {
|
||||
"astro:config:setup": ({ watchIntegration, config, updateConfig, logger }) => {
|
||||
watchIntegration(resolve())
|
||||
|
||||
return {
|
||||
"astro:config:setup": ({
|
||||
watchIntegration,
|
||||
config,
|
||||
updateConfig,
|
||||
logger
|
||||
}) => {
|
||||
// WATCH INTEGRATION FOR CHANGES
|
||||
watchIntegration(resolve())
|
||||
|
||||
// IMPORT INTEGRATIONS & INTEGRATION ROUTES
|
||||
const integrations = [...config.integrations];
|
||||
|
||||
// ADD ASTRO-EXPRESSIVE-CODE INTEGRATION
|
||||
if (!integrations.find(({ name }) => name === "astro-expressive-code")) {
|
||||
logger.info("Adding astro-expressive-code integration")
|
||||
updateConfig({
|
||||
integrations: [...integrations, ...astroGistsExpressiveCode()]
|
||||
})
|
||||
}
|
||||
|
||||
// UPDATE ASTRO-EXPRESSIVE-CODE INTEGRATION
|
||||
try {
|
||||
updateConfig({
|
||||
integrations: [...astroGistsExpressiveCode()]
|
||||
})
|
||||
} catch (e) {
|
||||
logger.error(e as string);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
import { Octokit } from "octokit";
|
||||
import { loadEnv } from "vite";
|
||||
|
||||
// Load environment variables
|
||||
const { GITHUB_PERSONAL_TOKEN } = loadEnv("all", process.cwd(), "GITHUB_");
|
||||
|
||||
// Create an Octokit instance
|
||||
export const octokit = new Octokit({ auth: GITHUB_PERSONAL_TOKEN });
|
||||
|
||||
// Get a Gist by ID
|
||||
export const getGist = async (gistId: string) => {
|
||||
const { data } = await octokit.request('GET /gists/{gist_id}', { gist_id: gistId });
|
||||
return data;
|
||||
};
|
||||
|
||||
// Get a file from a Gist by ID and filename
|
||||
export const getGistFile = async (
|
||||
gistId: string,
|
||||
filename: string
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { defineConfig } from "astro/config";
|
||||
import astroGist from "@matthiesenxyz/astro-gists";
|
||||
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
integrations: [astroGist()]
|
||||
|
|
Loading…
Reference in New Issue