Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix directory issue #22

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cypress/integration/Directory.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ Feature: Directory
| chasidic man | haiku/chasidic-man | smells like soup |
| in my parents house | haiku/in-my-parents-house | time feels old |
| Parent Directory | | Arturo |

Scenario: I visit a directory with a trailing slash
When I visit "haiku/"
And I click the link "dream haiku"
Then I see "exploding drum"
9 changes: 8 additions & 1 deletion src/components/Directory.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
? (Math.abs(num) / 1000).toFixed(1) + "k"
: `${Math.abs(num)}`;
}

function entryHref(entrySlug: string) {
if (isRoot) {
return `/${entrySlug}`
}
return `/${directory.slug}/${entrySlug}`
}
</script>

<style>
Expand Down Expand Up @@ -124,7 +131,7 @@
<td>
<a
sveltekit:prefetch
href="{directory.slug}/{entry.slug}">{entry.title}</a>
href="{entryHref(entry.slug)}">{entry.title}</a>
</td>
<td align="right">{entry.date}</td>
<td align="right">{format(entry.size)}</td>
Expand Down
8 changes: 8 additions & 0 deletions src/routes/__error.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<script context="module">
export function load({ error, status }) {
return {
props: { error, status }
};
}
</script>

<script lang="ts">
export let status: number;
export let error: Error;
Expand Down