Skip to content

Commit

Permalink
chore: filter out unnecessary showcases
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Freisler <[email protected]>
  • Loading branch information
FRSgit committed Sep 27, 2023
1 parent e9b5eed commit 81c2375
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/preview/next/pages/api/getShowcases.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import { NextApiRequest, NextApiResponse } from 'next';
import { showcasesFilter } from '@storefront-ui/preview-shared/utils/showcases.utils';

import { promise as glob } from 'glob-promise';

Expand All @@ -8,5 +9,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
cwd: path.join(process.cwd(), 'pages', 'showcases'),
});

res.status(200).json(fileContents);
res.status(200).json(showcasesFilter({ files: fileContents, ext: '.tsx' }));
}
6 changes: 5 additions & 1 deletion apps/preview/nuxt/pages/showcases.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ import {
} from '@storefront-ui/vue';
import { ref, watch, reactive, onBeforeMount } from 'vue';
import { useControlsSearchParams } from '~/composables/utils/useControlsSearchParams';
import { showcasesFilter } from '@storefront-ui/preview-shared/utils/showcases.utils';
const { currentRoute } = useRouter();
const REST_GROUP_NAME = 'Rest';
const files = import.meta.glob('./showcases/**');
const paths = Object.keys(files);
const paths = showcasesFilter({
files: Object.keys(files),
ext: '.vue',
});
const groupItemHref = (groupName, showcaseName) => {
return `/showcases/${groupName !== REST_GROUP_NAME ? `${groupName}/` : ''}${showcaseName}`;
};
Expand Down
4 changes: 4 additions & 0 deletions apps/preview/shared/utils/showcases.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const ignoredFiles = ['Alert/Alert'];

export const showcasesFilter = ({ files, ext }: { files: string[]; ext: string }) =>
files.filter((filePath) => !ignoredFiles.find((ignoredFile) => filePath.includes(`${ignoredFile}${ext}`)));

0 comments on commit 81c2375

Please sign in to comment.