[examples] Fix subdirectory (#3564)

This commit is contained in:
Andy
2020-01-10 17:15:22 +01:00
committed by Leo Lamprecht
parent 3fdea52ff9
commit bcbe0d8060

View File

@@ -44,21 +44,16 @@ export async function getGitHubRepoInfo(repo: Repo) {
branch: repo.branch, branch: repo.branch,
}; };
const subdirPath = const subdirPath = repo.repo + '/tree/' + repo.branch + '/';
repo.repo +
'/tree/' +
repo.branch +
'/' +
(data.id === 'zeit/now' ? 'examples/' : '');
if (repo.path.startsWith(subdirPath)) { if (repo.path.startsWith(subdirPath)) {
// subdir // subdir
data.subdir = repo.path.slice(subdirPath.length).split('/'); data.subdir = repo.path.slice(subdirPath.length).split('/');
} }
if (data.id === 'zeit/now' && data.subdir) { if (data.id === 'zeit/now' && data.subdir && data.subdir[0] === 'examples') {
// from our examples, add `homepage` and `description` fields // from our examples, add `homepage` and `description` fields
const example = data.subdir[0]; const example = data.subdir[1];
const exampleList = await getExampleList(); const exampleList = await getExampleList();
for (const item of exampleList) { for (const item of exampleList) {