New Resource

sveltin new resource

Command to create new resource (route).

Synopsis

Command used to create new resources.

Why “resource” instead of “route”? Although a resource is basically a route on SvelteKit router, a resource is not an empty route. The retional behind the name is related to the fact that to serve content a route alone is not enough. To name a few, we need libs, pages, endpoints, a place to serve static contents like images for the content belongs the route etc.

That’s why “resource”, all you need to group, serve and expose the content’s route.

This command:

  • Create a folder within “content” folder, so that you can add new content for the resource
  • Add the resource as route within the “src/routes” folder, creating its own folder
  • Scaffold a GET endpoint for the resource within “src/routes/api//
  • Scaffold +page.svelte component and +page.serve.ts endpoint to list all the content belongs to a resource
  • Scaffold [slug]/+page.svelte component and [slug]/+page.ts endpoint to get access to a specific content page

Usage

sveltin new resource [name] [flags]

Aliases

resource, r

Flags

  -g, --group string   Group name for resource routes (https://kit.svelte.dev/docs/advanced-routing#advanced-layouts)
  -h, --help           help for resource
      --slug           Use a different layout for the slug pages (https://kit.svelte.dev/docs/advanced-routing#advanced-layouts-layout)

SEE ALSO

Last updated: 07-Feb-2023

Apache 2.0 License @ 2021-present Sveltin.io and contributors .

The Sveltin logos are copyright © Mirco Veltri.