Skip to content

Commit

Permalink
docs: add README and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Aug 28, 2023
1 parent d104e10 commit dbd23fc
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 21 deletions.
67 changes: 46 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,63 @@
# create-svelte
# Prismic + SvelteKit Multi-Page Starter

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
Want to see an example of a multi-page website using [Prismic][prismic] and [SvelteKit][sveltekit]? Look no further! This project provides all the code you need for a personal website with a homepage, information pages, and navigation.

## Creating a project
- **Demo**: [Open live demo][live-demo]
- **Learn more about Prismic and SvelteKit**: [Prismic SvelteKit Documentation][prismic-docs]

If you're seeing this, you've probably already done this step. Congrats!
 

```bash
# create a new project in the current directory
npm create svelte@latest
<img src="https://user-images.githubusercontent.com/8601064/166617932-eaaa1643-f086-4909-9868-56234f8da98d.png" alt="Screenshots of the site seen on deskop and mobile browsers" />

# create a new project in my-app
npm create svelte@latest my-app
&nbsp;

## 🚀 Quick Start

To start a new project using this starter, run the following commands in your terminal:

```sh
npx @slicemachine/init@latest --starter sveltekit-starter-prismic-multi-page
```

## Developing
The commands will do the following:

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
1. Start a new SvelteKit project using this starter.
2. Ask you to log in to Prismic or [create an account][prismic-sign-up].
3. Create a new Prismic content repository with sample content.

```bash
npm run dev
When you're ready to start your project, run the following command:

# or start the server and open the app in a new browser tab
npm run dev -- --open
```sh
npm run dev
```

## Building
## Documentation

To create a production version of your app:
To learn how to work with your new project, [**see this starter's docs**][starter-docs].

To learn more about working with Prismic, [**see the Prismic docs**][prismic-docs].

## License

```bash
npm run build
```
Copyright 2013-2022 Prismic <[email protected]> (https://prismic.io)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
You can preview the production build with `npm run preview`.
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
[prismic]: https://prismic.io/
[prismic-docs]: https://prismic.io/docs/technologies/sveltekit
[prismic-sign-up]: https://prismic.io/dashboard/signup
[sveltekit]: https://kit.svelte.dev/
[starter-docs]: ./docs/README.md
[live-demo]: https://sveltekit-starter-prismic-multi-page.vercel.app/
101 changes: 101 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Prismic + SvelteKit Multi-Page Starter

This page covers how to use **Prismic + SvelteKit Multi-Page Starter** with Prismic.

- **Demo**: [Open live demo][live-demo]
- **Learn more about Prismic and SvelteKit**: [Prismic SvelteKit Documentation][prismic-docs]

&nbsp;

<img src="https://user-images.githubusercontent.com/8601064/166617932-eaaa1643-f086-4909-9868-56234f8da98d.png" alt="Screenshots of the site seen on deskop and mobile browsers" />

&nbsp;

## 🚀 Quick Start

To start a new project using this starter, run the following commands in your terminal:

```sh
npx @slicemachine/init --starter sveltekit-starter-prismic-multi-page
```

The commands will do the following:

1. Start a new SvelteKit project using this starter.
2. Ask you to log in to Prismic or [create an account][prismic-sign-up].
3. Create a new Prismic content repository with sample content.

When you're ready to start your project, run the following command:

```sh
npm run dev
```

To learn more about working with Prismic, [**see the Prismic docs**](https://prismic.io/docs/technologies/sveltekit).

## Using and customizing your project

To get started after creating your new project, go to [prismic.io/dashboard](https://prismic.io/dashboard), click on the repository for this website, and start editing.

### Create a page

To create a page, click on the green pencil icon, then select **Page**.

Your new page will be accessible by its URL, but it won't appear on the website automatically. To let users discover it, add it to the navigation.

### Update the navigation

To add a page to your navigation menu, go to the document list and open the **Navigation** document. In the **Links** group, click **Add a new element in Links**. Select the page to add and fill in a label.

### Customize this website

This website is preconfigured with Prismic. It has three Prismic packages installed:

- `@prismicio/client` provides helpers for fetching content from Prismic
- `@prismicio/svelte` provides Svelte components for rendering content from Prismic

These packages are already integrated and employed in this app. Take a look at the code to see how they're used.

### Edit the code

There are two steps to rendering content from Prismic in your SvelteKit project:

1. Fetch content from the Prismic API using `@prismicio/client`.
2. Template the content using components from `@prismicio/react`.

Here are some of the files in your project that you can edit:

- `src/lib/prismicio.js` - This file includes configuration for `@prismicio/client` and exports useful API helpers.
- `src/routes/+layout.svelte` - This is your layout component.
- `src/routes/+page.svelte` - This is the app homepage. It queries and renders a page document with the UID (unique identifier) "home" from the Prismic API.
- `src/routes/[uid]/+page.svelte` - This is the page component, which queries and renders a page document from your Prismic repository based on the UID.
- `src/lib/slices/\*/index.svelte` - Each Slice in your project has an `index.svelte` file that renders the Slice component. Edit this file to customize your Slices.

These are important files that you should leave as-is:

- `src/routes/slice-simulator/+page.svelte` - Do not edit or delete this file. This file simulates your Slice components in development.
- `src/lib/slices/` - This directory contains Slice components, which are generated programmatically by Slice Machine. To customize a Slice template, you can edit the Slice's index.js file. To add Slices, delete Slices, or edit Slice models, use Slice Machine (more info below).

Learn more about how to edit your components with [Fetch Data in SvelteKit](https://prismic.io/docs/technologies/fetch-data-sveltekit) and [Template Content in SvelteKit](https://prismic.io/docs/technologies/template-content-sveltekit).

Styling in this project is implemented with Tailwind CSS. See the [Tailwind docs](https://tailwindcss.com/docs) for more info.

### Deploy to the web

To put your project online, see [Deploy your SvelteKit App](https://prismic.io/docs/technologies/deploy-sveltekit).

### Edit content models with Slice Machine

This project includes an application called Slice Machine, which generates models for your Custom Types and Slices. Slice Machine stores the models locally in your codebase, so you can save and version them. It also syncs your models to Prismic. To learn how to use Slice Machine, read [Model Content in SvelteKit](https://prismic.io/docs/technologies/model-content-sveltekit).

If you change or add to your Custom Types, you'll need to update your route handling to match. To learn how to do that, read [Define Paths in SvelteKit](https://prismic.io/docs/technologies/define-paths-sveltekit).

## Learn more

For the official Prismic documentation, see [Prismic's guide for SvelteKit](https://prismic.io/docs/technologies/sveltekit) or the [technical references for the installed Prismic packages](https://prismic.io/docs/technologies/technical-references).

[prismic]: https://prismic.io/
[prismic-docs]: https://prismic.io/docs/technologies/sveltekit
[prismic-sign-up]: https://prismic.io/dashboard/signup
[sveltekit]: https://sveltekit.org/
[live-demo]: https://sveltekit-starter-prismic-multi-page.vercel.app/

0 comments on commit dbd23fc

Please sign in to comment.