Skip to content

Commit 6168316

Browse files
author
Amelia Wattenberger
committed
fix branch sha, update config
1 parent 88e7df7 commit 6168316

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

blocks.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[
22
{
33
"type": "folder",
4-
"id": "preview-block",
4+
"id": "preview-folder-block",
55
"title": "Preview Block",
6-
"description": "Preview your site",
6+
"description": "Preview your site (from a folder)",
77
"entry": "blocks/preview-folder-block.tsx",
88
"matches": ["*"],
99
"example_path": "https://github.com/githubnext/blocks-preview-experiment"
@@ -12,7 +12,7 @@
1212
"type": "file",
1313
"id": "preview-file-block",
1414
"title": "Preview Block",
15-
"description": "Preview your site",
15+
"description": "Preview your site (from a file)",
1616
"entry": "blocks/preview-file-block.tsx",
1717
"matches": ["*.tsx, *.ts, *.jsx, *.js"],
1818
"example_path": "https://github.com/githubnext/blocks-preview-experiment/blob/main/pages/about.tsx"

blocks/preview-file-block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function (props: FolderBlockProps) {
2828
src={url}
2929
style={{
3030
width: "100%",
31-
height: "100%",
31+
height: "100vh",
3232
border: "none",
3333
}}
3434
/>

blocks/preview-folder-block.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ export default function (props: FolderBlockProps) {
88
const url = `https://${context.owner}.github.io/${context.repo}/${sha}`
99

1010
const updateSha = async () => {
11-
if (sha !== "HEAD") return
12-
const res = await onRequestGitHubData(`/repos/${context.owner}/${context.repo}/git/refs/heads/main`);
11+
const isShaBranchName = context.sha.length !== 40;
12+
if (!isShaBranchName) return
13+
const res = await onRequestGitHubData(
14+
`/repos/${context.owner}/${context.repo}/git/refs/heads/${context.sha}`
15+
);
1316
const defaultSha = res.object.sha
1417
setSha(defaultSha)
1518
}
@@ -22,7 +25,7 @@ export default function (props: FolderBlockProps) {
2225
src={url}
2326
style={{
2427
width: "100%",
25-
height: "100%",
28+
height: "100vh",
2629
border: "none",
2730
}}
2831
/>

0 commit comments

Comments
 (0)