Skip to content

Commit a91a296

Browse files
committed
[feat] __hidden file to mark folders as hidden
1 parent 2fc0409 commit a91a296

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ The next steps depend on whether you want to run this locally in filesystem mode
2121

2222
1. if an `.env` file exists, modify it so there's `PUBLIC_USE_FILESYSTEM=` in it
2323
2. Run the app locally with `pnpm dev` or `pnpm build && pnpm preview`.
24+
25+
## Creating new tutorials
26+
27+
Tutorials live inside `content`. Each tutorial consists of a `README.md`, which is the text to the left, and `app-a` and `app-b` folders, which represent the initial and solved state. Files that stay the same can be omitted from `app-b`. Files are marked as deleted in `app-b` if they start with `__delete`. Folders that are marked as deleted in `app-b` if they contain a file named `__delete`. Folders that contain a file named `__hidden` are not visible in the file tree.

src/routes/tutorial/[slug]/Folder.svelte

+12-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,19 @@
3232
const { edit, add, remove } = getContext('filetree');
3333
3434
$: _files = files || []; // workaround for what seems to be a Svelte bug, where files is undefined on navigation
35+
$: hidden_children = _files
36+
.filter((file) =>
37+
file.name.startsWith(prefix + file.name.slice(prefix.length).split('/').shift() + '/__hidden')
38+
)
39+
.map((file) => file.name.slice(0, -'/__hidden'.length));
3540
$: children = _files
36-
.filter((file) => file.name.startsWith(prefix))
41+
.filter(
42+
(file) =>
43+
file.name.startsWith(prefix) &&
44+
!hidden_children.some(
45+
(hidden) => file.name.startsWith(hidden + '/') || file.name === hidden
46+
)
47+
)
3748
.sort((a, b) => (a.name < b.name ? -1 : 1));
3849
$: child_directories = children.filter(
3950
(child) => child.depth === depth + 1 && child.type === 'directory'

0 commit comments

Comments
 (0)