[example/538] - individual pages (#865)

* [example/538] - individual pages

* [examples/538][sm] - force inclusion of classes

* [examples/538] - changes requested by demenech
This commit is contained in:
Luccas Mateus
2023-05-10 18:13:16 -03:00
committed by GitHub
parent 3f350f8fcd
commit f610c953e7
12 changed files with 2871 additions and 233 deletions

View File

@@ -0,0 +1,38 @@
import { Octokit } from 'octokit';
export interface GithubProject {
owner: string;
repo: string;
branch: string;
files: string[];
readme: string;
description?: string;
name?: string;
}
export async function getProjectReadme(
owner: string,
repo: string,
branch: string,
readme: string,
github_pat?: string
) {
const octokit = new Octokit({ auth: github_pat });
try {
const response = await octokit.rest.repos.getContent({
owner,
repo,
path: readme,
ref: branch,
});
const data = response.data as { content?: string };
const fileContent = data.content ? data.content : '';
if (fileContent === '') {
return null;
}
const decodedContent = Buffer.from(fileContent, 'base64').toString();
return decodedContent;
} catch (error) {
return null;
}
}