Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is not working #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 186 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"dependencies": {
"@astrojs/netlify": "^5.1.3",
"astro": "^4.5.2",
"crypto-js": "^4.2.0",
"date-fns": "^3.3.1",
"dotenv": "^16.4.5"
"dotenv": "^16.4.5",
"urlbox": "^2.1.0"
}
}
27 changes: 27 additions & 0 deletions src/pages/urlbox.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
// npm install urlbox --save

import Urlbox from "urlbox";


const { Urlbox_Pub_Key } = import.meta.env;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Vite allows for deconstructions of env variables. You have to do const Urlbox_Pub_Key = import.meta.env.Urlbox_Pub_Key.

But I would go with the standard uppercase so: const Urlbox_Pub_Key = import.meta.env.URLBOX_PUB_KEY

const { Urlbox_Secret_Key } = import.meta.env;

// Plugin your API key and secret
const urlbox = Urlbox(Urlbox_Pub_Key, Urlbox_Secret_Key);

// Set your options
const options = {
url: "github.com",
thumb_width: 600,
format: "jpg",
quality: 80,
};

const imgUrl = urlbox.generateRenderLink(options);
// https://api.urlbox.io/v1/YOUR_API_KEY/TOKEN/jpg?url=github.com&thumb_width=600&quality=80

// Now set it as the src in an img tag to render the screenshot
---

<img src={imgUrl} />;