diff --git a/demo/src/pages/gist.astro b/demo/src/pages/gist.astro
new file mode 100644
index 0000000..70f7697
--- /dev/null
+++ b/demo/src/pages/gist.astro
@@ -0,0 +1,17 @@
+---
+import * as Component from 'astro-embed';
+import Base from '../layouts/Base.astro';
+---
+
+
+
All files
+
+
+ Specific file
+
+
diff --git a/demo/src/pages/index.astro b/demo/src/pages/index.astro
index 2c0c736..7850666 100644
--- a/demo/src/pages/index.astro
+++ b/demo/src/pages/index.astro
@@ -14,6 +14,9 @@ import Base from '../layouts/Base.astro';
<YouTube/>
component examples
+
+ <Gist/>
component examples
+
Other examples
diff --git a/demo/src/pages/integration.mdx b/demo/src/pages/integration.mdx
index 4f6368f..51db86e 100644
--- a/demo/src/pages/integration.mdx
+++ b/demo/src/pages/integration.mdx
@@ -21,3 +21,5 @@ https://twitter.com/astrodotbuild/status/1511750228428435457
https://vimeo.com/32001208
http://www.youtube.com/watch?v=Hoe-woAhq_k
+
+https://gist.github.com/vasfvitor/1f995c47ee82ae652496622db1e678ea
diff --git a/package-lock.json b/package-lock.json
index c85806c..5e5686c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -70,6 +70,10 @@
"resolved": "demo",
"link": true
},
+ "node_modules/@astro-community/astro-embed-gist": {
+ "resolved": "packages/astro-embed-gist",
+ "link": true
+ },
"node_modules/@astro-community/astro-embed-integration": {
"resolved": "packages/astro-embed-integration",
"link": true
@@ -1940,9 +1944,9 @@
"dev": true
},
"node_modules/@types/unist": {
- "version": "2.0.9",
- "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.9.tgz",
- "integrity": "sha512-zC0iXxAv1C1ERURduJueYzkzZ2zaGyc+P2c95hgkikHPr3z8EdUZOlgEQ5X0DRmwDZn+hekycQnoeiiRVrmilQ=="
+ "version": "2.0.10",
+ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
+ "integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA=="
},
"node_modules/@types/yargs-parser": {
"version": "21.0.0",
@@ -9747,11 +9751,11 @@
}
},
"packages/astro-embed": {
- "version": "0.5.1",
+ "version": "0.6.0",
"license": "MIT",
"dependencies": {
- "@astro-community/astro-embed-integration": "^0.5.1",
- "@astro-community/astro-embed-twitter": "^0.5.1",
+ "@astro-community/astro-embed-integration": "^0.6.0",
+ "@astro-community/astro-embed-twitter": "^0.5.2",
"@astro-community/astro-embed-vimeo": "^0.3.1",
"@astro-community/astro-embed-youtube": "^0.4.1"
},
@@ -9759,12 +9763,23 @@
"astro": "^2.0.0 || ^3.0.0-beta"
}
},
+ "packages/astro-embed-gist": {
+ "name": "@astro-community/astro-embed-gist",
+ "version": "0.5.2",
+ "license": "MIT",
+ "dependencies": {
+ "@astro-community/astro-embed-utils": "^0.1.0"
+ },
+ "peerDependencies": {
+ "astro": "^2.0.0 || ^3.0.0-beta || ^4.0.0-beta"
+ }
+ },
"packages/astro-embed-integration": {
"name": "@astro-community/astro-embed-integration",
- "version": "0.5.1",
+ "version": "0.6.0",
"license": "MIT",
"dependencies": {
- "@astro-community/astro-embed-twitter": "^0.5.1",
+ "@astro-community/astro-embed-twitter": "^0.5.2",
"@astro-community/astro-embed-vimeo": "^0.3.1",
"@astro-community/astro-embed-youtube": "^0.4.1",
"@types/unist": "^2.0.0",
@@ -9782,7 +9797,7 @@
},
"packages/astro-embed-twitter": {
"name": "@astro-community/astro-embed-twitter",
- "version": "0.5.1",
+ "version": "0.5.2",
"license": "MIT",
"dependencies": {
"@astro-community/astro-embed-utils": "^0.1.0"
@@ -9852,10 +9867,16 @@
"astro": "^2.8.3"
}
},
+ "@astro-community/astro-embed-gist": {
+ "version": "file:packages/astro-embed-gist",
+ "requires": {
+ "@astro-community/astro-embed-utils": "^0.1.0"
+ }
+ },
"@astro-community/astro-embed-integration": {
"version": "file:packages/astro-embed-integration",
"requires": {
- "@astro-community/astro-embed-twitter": "^0.5.1",
+ "@astro-community/astro-embed-twitter": "^0.5.2",
"@astro-community/astro-embed-vimeo": "^0.3.1",
"@astro-community/astro-embed-youtube": "^0.4.1",
"@types/unist": "^2.0.0",
@@ -11282,9 +11303,9 @@
"dev": true
},
"@types/unist": {
- "version": "2.0.9",
- "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.9.tgz",
- "integrity": "sha512-zC0iXxAv1C1ERURduJueYzkzZ2zaGyc+P2c95hgkikHPr3z8EdUZOlgEQ5X0DRmwDZn+hekycQnoeiiRVrmilQ=="
+ "version": "2.0.10",
+ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
+ "integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA=="
},
"@types/yargs-parser": {
"version": "21.0.0",
@@ -11668,8 +11689,8 @@
"astro-embed": {
"version": "file:packages/astro-embed",
"requires": {
- "@astro-community/astro-embed-integration": "^0.5.1",
- "@astro-community/astro-embed-twitter": "^0.5.1",
+ "@astro-community/astro-embed-integration": "^0.6.0",
+ "@astro-community/astro-embed-twitter": "^0.5.2",
"@astro-community/astro-embed-vimeo": "^0.3.1",
"@astro-community/astro-embed-youtube": "^0.4.1"
}
diff --git a/packages/astro-embed-gist/Gist.astro b/packages/astro-embed-gist/Gist.astro
new file mode 100644
index 0000000..ca258b1
--- /dev/null
+++ b/packages/astro-embed-gist/Gist.astro
@@ -0,0 +1,73 @@
+---
+export interface Props {
+ /**
+ * Gist url to fetch
+ */
+ id: string;
+ /**
+ * Optional file name to fetch, case sensitive
+ */
+ fileName?: string;
+}
+const { id, fileName } = Astro.props;
+let url = id + '.json';
+if (fileName) {
+ url += `?file=${fileName}`;
+}
+
+async function fetchGist(id: string) {
+ try {
+ const gistUrl = new URL(url);
+ return (await fetch(gistUrl).then((res) => res.json())) as {
+ description: string;
+ created_at: Date;
+ files: string[];
+ owner: string;
+ stylesheet: string;
+ div: string;
+ };
+ } catch (e) {
+ console.error(
+ `[error] astro-embed
+ ${e.status} - ${e.statusText}: Failed to fetch gist ${id}`
+ );
+ }
+}
+const gist = await fetchGist(id);
+
+// TODO use stylesheet
+const stylesheetUrl = gist?.stylesheet;
+---
+
+{
+ gist && (
+
+ {gist.description}
+
+ gist by {gist.owner}
+
+ )
+}
+
+
+
diff --git a/packages/astro-embed-gist/index.ts b/packages/astro-embed-gist/index.ts
new file mode 100644
index 0000000..8285dd1
--- /dev/null
+++ b/packages/astro-embed-gist/index.ts
@@ -0,0 +1 @@
+export { default as Gist } from './Gist.astro';
diff --git a/packages/astro-embed-gist/package.json b/packages/astro-embed-gist/package.json
new file mode 100644
index 0000000..1032dce
--- /dev/null
+++ b/packages/astro-embed-gist/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "@astro-community/astro-embed-gist",
+ "version": "0.5.2",
+ "description": "Component to easily embed Gists on your Astro site",
+ "type": "module",
+ "exports": {
+ ".": "./index.ts",
+ "./matcher": "./matcher.ts"
+ },
+ "files": [
+ "index.ts",
+ "Gist.astro"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/delucis/astro-embed.git"
+ },
+ "keywords": [
+ "astro",
+ "astro-component",
+ "embeds",
+ "gist"
+ ],
+ "author": "delucis",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/delucis/astro-embed/issues"
+ },
+ "homepage": "https://github.com/delucis/astro-embed/tree/main/packages/astro-embed-gist#readme",
+ "dependencies": {
+ "@astro-community/astro-embed-utils": "^0.1.0"
+ },
+ "peerDependencies": {
+ "astro": "^2.0.0 || ^3.0.0-beta || ^4.0.0-beta"
+ }
+}
diff --git a/packages/astro-embed/index.ts b/packages/astro-embed/index.ts
index b40d162..49df72c 100644
--- a/packages/astro-embed/index.ts
+++ b/packages/astro-embed/index.ts
@@ -1,3 +1,4 @@
export { Tweet } from '@astro-community/astro-embed-twitter';
export { YouTube } from '@astro-community/astro-embed-youtube';
export { Vimeo } from '@astro-community/astro-embed-vimeo';
+export { Gist } from '@astro-community/astro-embed-gist';