Skip to content

Commit 0436bc8

Browse files
authored
Restore link.js
1 parent cfbe8fa commit 0436bc8

File tree

1 file changed

+9
-59
lines changed

1 file changed

+9
-59
lines changed

api/link.js

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
11

2-
export default async function handler(request, response) {
2+
export default function handler(request, response) {
33

44
const query = request.query;
55

66
let title = 'Codeit | Mobile code editor connected to Git';
7-
let desc = 'Run JavaScript projects, code your ideas, and share it all on Codeit.';
8-
let twitterTitle = false;
9-
10-
11-
const https = require('https');
12-
13-
function getRequest(url) {
14-
15-
return new Promise(resolve => {
16-
17-
const req = https.get(url, (resp) => {
18-
19-
let data = '';
20-
21-
resp.on('data', (chunk) => {
22-
23-
data += chunk;
24-
25-
});
26-
27-
resp.on('end', () => {
28-
29-
resolve({status: resp.statusCode, data: data});
30-
31-
});
32-
33-
});
34-
35-
});
36-
37-
}
38-
39-
7+
408
if (query.url) {
419

4210
// parse URL
@@ -55,38 +23,20 @@ export default async function handler(request, response) {
5523

5624
}
5725

58-
59-
const repoName = url[0] + '/' + url[1].split(':')[0];
60-
61-
62-
console.log('https://api.github.com/repos/' + repoName);
63-
64-
const {status, resp} = await getRequest('https://api.github.com/repos/' + repoName);
65-
66-
console.log(resp);
67-
68-
//const repoDesc = JSON.parse(resp).description;
69-
70-
//if (repoDesc) desc = repoDesc;
71-
//else desc = '';
72-
73-
7426
if (url[url.length-1].endsWith('.html')
7527
|| url[url.length-1].endsWith('.svg')) {
7628

77-
title = 'Run ' + repoName + ' on Codeit';
29+
title = 'Run ' + url[0] + '/' + url[1].split(':')[0] + ' with Codeit';
7830

7931
} else {
8032

81-
title = repoName + ' on Codeit';
33+
title = 'Open ' + url[0] + '/' + url[1].split(':')[0] + ' with Codeit';
8234

8335
}
8436

8537
}
8638

8739
}
88-
89-
if (!twitterTitle) twitterTitle = title;
9040

9141

9242

@@ -106,25 +56,25 @@ const html = `
10656
<meta name="apple-mobile-web-app-title" content="Codeit">
10757
10858
<meta charset="utf-8">
109-
<meta name="description" content="`+ desc +`">
59+
<!-- <meta name="description" content="Run JavaScript projects, code your ideas, and share it all on Codeit."> -->
11060
11161
<meta property="og:title" content="`+ title +`">
112-
<meta property="og:description" content="`+ desc +`">
62+
<!-- <meta property="og:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit."> -->
11363
<meta property="og:url" content="https://codeit.codes">
11464
<meta property="og:image" content="https://codeit.codes/images/banner-og.png">
11565
<meta property="og:type" content="video.other">
11666
<meta property="og:site_name" content="Codeit">
11767
<meta property="og:video:url" content="https://codeit.codes/api/link?url=`+ query.url +`">
11868
<meta property="og:video:secure_url" content="https://codeit.codes/api/link?url=`+ query.url +`">
11969
<meta property="og:video:type" content="text/html">
120-
<meta property="og:video:width" content="128'https://api.github.com/repos/' + 0">
70+
<meta property="og:video:width" content="1280">
12171
<meta property="og:video:height" content="720">
12272
123-
<meta property="twitter:title" content="`+ twitterTitle +`">
73+
<meta property="twitter:title" content="`+ title +`">
12474
<meta property="twitter:site" content="@codeitcodes">
12575
<meta name="twitter:card" content="player">
12676
<meta property="twitter:domain" content="https://codeit.codes/">
127-
<meta name="twitter:description" content="`+ desc +`">
77+
<!-- <meta name="twitter:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit."> -->
12878
<meta name="twitter:image" content="https://codeit.codes/images/banner-og.png">
12979
<meta name="twitter:player" content="https://codeit.codes/api/link?url=`+ query.url +`">
13080
<meta name="twitter:player:stream:content_type" content="text/html">

0 commit comments

Comments
 (0)