Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

add a path option to each exercise#133

Merged
Rich-Harris merged 1 commit intomainfromgh-119
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
---
title: Route parameters
path: /blog
---

To create routes with dynamic parameters, use square brackets around a valid variable name. For example, a file like `src/routes/blog/[slug]/+page.svelte` will create a route that matches `/blog/one`, `/blog/two`, `/blog/three` and so on.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
---
title: Page data
path: /blog
---

At its core, SvelteKit's job boils down to three things:
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
---
title: Layout data
path: /blog
---

Just as `+layout.svelte` files create UI for every child route, `+layout.server.js` files load data for every child route.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
---
title: Param matchers
path: /colors/ff3e00
---

To prevent the router from matching on invalid input, you can specify a _matcher_. For example, you might want a route like `/colors/[value]` to match hex values like `/colors/ff3e00` but not named colors like `/colors/octarine` or any other arbitrary input.
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
---
title: Invalidation
path: /Europe/London
---

When the user navigates from one page to another, SvelteKit calls your `load` functions, but only if it thinks something has changed.
Expand Down

This file was deleted.

9 changes: 6 additions & 3 deletionssrc/lib/server/content.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export function get_index() {

const text = fs.readFileSync(`${dir}/README.md`, 'utf-8');
const { frontmatter, markdown } = extract_frontmatter(text, dir);
const { title } = frontmatter;
const { title, path = '/', focus } = frontmatter;
const slug = exercise.slice(3);
const meta = fs.existsSync(`${dir}/meta.json`) ? json(`${dir}/meta.json`) : {};

Expand All@@ -78,7 +78,9 @@ export function get_index() {
exercises.push(
(last_exercise = {
slug: exercise.slice(3),
title: frontmatter.title,
title,
path,
focus,
markdown,
dir,
prev: last_exercise ? { slug: last_exercise.slug } : null,
Expand DownExpand Up@@ -164,8 +166,9 @@ export function get_exercise(slug) {
title: chapter.meta.title
},
scope,
focus: chapter.meta.focus ?? part.meta.focus,
focus:exercise.focus ??chapter.meta.focus ?? part.meta.focus,
title: exercise.title,
path: exercise.path,
slug: exercise.slug,
prev: exercise.prev,
next: exercise.next,
Expand Down
4 changes: 4 additions & 0 deletionssrc/lib/types/index.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,6 +43,8 @@ export interface Exercise {
scope: Scope;
focus: string;
title: string;
/** the initial path to navigate to */
path: string;
slug: string;
prev: { slug: string } | null;
next: { slug: string; title: string } | null;
Expand All@@ -58,6 +60,8 @@ export interface Exercise {

export interface ExerciseRaw {
title: string;
path: string;
focus: string;
slug: string;
prev: { slug: string } | null;
next: { slug: string; title: string } | null;
Expand Down
17 changes: 7 additions & 10 deletionssrc/routes/tutorial/[slug]/+page.svelte
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@
import Chrome from './Chrome.svelte';
import Icon from '@sveltejs/site-kit/components/Icon.svelte';
import Loading from './Loading.svelte';
import { PUBLIC_USE_FILESYSTEM } from '$env/static/public';
import ScreenToggle from './ScreenToggle.svelte';
import Filetree from '$lib/components/filetree/Filetree.svelte';

Expand DownExpand Up@@ -45,7 +44,7 @@
$: completed =
Object.keys(complete_states).length > 0 && Object.values(complete_states).every(Boolean);

let path ='/';
let path =data.exercise.path;

let width = browser ? window.innerWidth : 1000;
let selected_view = 0;
Expand DownExpand Up@@ -116,12 +115,10 @@
if (adapter) {
reload_iframe = await adapter.reset(stubs);
} else {
const module = PUBLIC_USE_FILESYSTEM
? await import('$lib/client/adapters/filesystem/index.js')
: await import('$lib/client/adapters/webcontainer/index.js');
const module = await import('$lib/client/adapters/webcontainer/index.js');

adapter = await module.create(stubs);
set_iframe_src(adapter.base);
set_iframe_src(adapter.base + path);
}

await new Promise((fulfil, reject) => {
Expand All@@ -140,7 +137,7 @@
if (!called && adapter) {
// Updating the iframe too soon sometimes results in a blank screen,
// so we try again after a short delay if we haven't heard back
set_iframe_src(adapter.base);
set_iframe_src(adapter.base + path);
}
}, 5000);

Expand All@@ -151,9 +148,9 @@
}, 10000);
});

if (reload_iframe) {
if (reload_iframe || iframe.src !== adapter.base + data.exercise.path) {
await new Promise((fulfil) => setTimeout(fulfil, 200));
set_iframe_src(adapter.base);
set_iframe_src(adapter.base + data.exercise.path);
}

return adapter;
Expand DownExpand Up@@ -214,7 +211,7 @@
clearTimeout(reload_timeout);
reload_timeout = setTimeout(() => {
if (adapter) {
set_iframe_src(adapter.base);
set_iframe_src(adapter.base + path);
}
}, 1000);
}
Expand Down
3 changes: 1 addition & 2 deletionssrc/routes/tutorial/[slug]/Loading.svelte
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@
import { createEventDispatcher } from 'svelte';
import { tweened } from 'svelte/motion';
import { quadInOut } from 'svelte/easing';
import { PUBLIC_USE_FILESYSTEM } from '$env/static/public';

/** @type {boolean} */
export let initial;
Expand DownExpand Up@@ -58,7 +57,7 @@
{/if}

<div style="display: flex; align-items: center;">
{#if!PUBLIC_USE_FILESYSTEM &&initial}
{#if initial}
<ul>
<li>Booting WebContainer</li>
{#if $grayscale < 0.65}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp