Skip to content

Commit 287e4e2

Browse files
committed
add edit this page links - closes #21
1 parent eb5467f commit 287e4e2

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/lib/server/content.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function get_section(slug) {
106106
slug: section.slug,
107107
prev: section.prev,
108108
next: section.next,
109+
dir: section.dir,
109110
html: transform(section.markdown), // TODO syntax highlighting
110111
a,
111112
b

src/lib/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface Section {
3737
prev: string | null;
3838
next: string | null;
3939
html: string;
40+
dir: string;
4041
a: Record<string, Stub>;
4142
b: Record<string, Stub>;
4243
}

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import Editor from './_/Editor.svelte';
2020
import Folder from './_/Folder.svelte';
2121
import { monaco } from '$lib/client/monaco/monaco.js';
22+
import { Icon } from '@sveltejs/site-kit';
2223
2324
/** @type {import('$lib/types').SectionIndex} */
2425
export let index;
@@ -169,9 +170,11 @@
169170

170171
<div class="text">{@html section.html}</div>
171172

172-
{#if Object.keys(section.b).length > 0}
173-
<div class="controls" />
174-
{/if}
173+
<footer>
174+
<a class="edit" href="https://github.com/sveltejs/learn.svelte.dev/tree/main/{section.dir}">
175+
<Icon size={16} name="edit" /> Edit this page
176+
</a>
177+
</footer>
175178
</section>
176179

177180
<section slot="b">
@@ -337,13 +340,20 @@
337340
list-style-position: inside;
338341
}
339342
340-
.controls {
341-
padding: 1rem 3rem;
343+
.content footer {
344+
padding: 1rem 4rem;
342345
display: flex;
343346
justify-content: space-between;
344347
border-top: 1px solid rgba(255, 255, 255, 0.1);
345348
}
346349
350+
.content footer a {
351+
color: var(--sidebar-text);
352+
font-size: 1.4rem;
353+
display: flex;
354+
gap: 0.5rem;
355+
}
356+
347357
.navigator {
348358
background: #f9f9f9;
349359
display: flex;

0 commit comments

Comments
 (0)