Skip to content

Commit bd90db7

Browse files
Better export data prune (#765)
* fix for empty layers toggle showing small circle * better-export-data-prune now removes all lf's before and after some variation of `export { data };` - for example source - for stackblitz code * added needed LF. not sure how that happend. Looks right now.
1 parent 15537ae commit bd90db7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/src/lib/examples.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function loadExample(
2828
default: Component;
2929
layers?: string[];
3030
};
31-
const source = (rawSource.default as string).replace(/^.*export .*;.*$/gm, '');
31+
const source = (rawSource.default as string).replace(/(\n\s*)*^.*export .*;.*$(\n\s*)*/gm, '\n');
3232

3333
return { component: comp, source, module };
3434
} catch (e) {
@@ -84,7 +84,7 @@ export async function loadExampleByPath(resolvedPath: string): Promise<LoadedExa
8484
}
8585

8686
const comp = componentModule.default as Component;
87-
const source = (rawSource as string).replace(/^.*export .*;.*$/gm, '');
87+
const source = (rawSource as string).replace(/(\n\s*)*^.*export .*;.*$(\n\s*)*/gm, '\n');
8888

8989
return { component: comp, source };
9090
} catch (e) {

docs/src/lib/stackblitz.remote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const getExample = query(
177177
}
178178

179179
// Remove `export { data };` from the code
180-
const cleanCode = code.replace(/^.*export .*;.*$/gm, '');
180+
const cleanCode = code.replace(/(\n\s*)*^.*export .*;.*$(\n\s*)*/gm, '\n');
181181

182182
// Prepare additional files to include
183183
const additionalFiles: Record<string, string> = {};

docs/src/routes/docs/screenshot/[component]/+layout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const load = async ({ params }) => {
1818
const source = (await componentSources[path]()) as string;
1919

2020
// Remove `export { data };`
21-
const cleanupSource = source.replace(/^.*export .*;.*$/gm, '');
21+
const cleanupSource = source.replace(/(\n\s*)*^.*export .*;.*$(\n\s*)*/gm, '\n');
2222

2323
if (!examples[comp]) {
2424
examples[comp] = {};

0 commit comments

Comments
 (0)