Skip to content
Personal blog, open sourced; get a peek to what I'm up to. Fix my typos and my poor english.
HTML JavaScript CSS Shell HCL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Try to add cypress.io testing to GitHub Actions workflow Jun 16, 2019
.theia Add some git config and hopefully a better docker image for gitpod to… Jun 28, 2019
cypress i18n multi-language support + blog post about this Jul 4, 2019
src
static i18n multi-language support + blog post about this Jul 4, 2019
.gitignore initial commit Jun 11, 2019
.gitpod.yml Add some git config and hopefully a better docker image for gitpod to… Jun 28, 2019
.prettierrc Initial commit from gatsby: (https://github.com/gatsbyjs/gatsby-start… Mar 3, 2019
LICENSE
README.md
appveyor.yml
cypress.json Adds Cypress tests to migrate gatbsyjs blog to sapper with non-regres… Jun 11, 2019
package-lock.json New blog post about assembling samples into something.. useful? to me… Jun 21, 2019
package.json New blog post about assembling samples into something.. useful? to me… Jun 21, 2019
webpack.config.js initial commit Jun 11, 2019

README.md

David's Blog

Netlify Status Actions Status

See it live here: https://lacourt.dev/

This is a Sapper backed blog with webpack. To clone it and get started:

git clone https://github.com/doppelganger9/blog.git
cd david-blog
npm install
npm run dev

Open up localhost:3000 and start clicking around.

Consult sapper.svelte.dev for help getting started.

Open source

You can follow in the commit history how I migrated from the Gastby-starter-blog to grow my own thing.

I encourage your curiosity and will be delighted if you can fix my poor English grammar or whatever deeper in the content I will post.

Structure

Sapper expects to find two directories in the root of your project — src and static.

src

The src directory contains the entry points for your app — client.js, server.js and (optionally) a service-worker.js — along with a template.html file and a routes directory.

src/routes

This is the heart of your Sapper app. There are two kinds of routes — pages, and server routes.

Pages are Svelte components written in .svelte files. When a user first visits the application, they will be served a server-rendered version of the route in question, plus some JavaScript that 'hydrates' the page and initialises a client-side router. From that point forward, navigating to other pages is handled entirely on the client for a fast, app-like feel. (Sapper will preload and cache the code for these subsequent pages, so that navigation is instantaneous.)

Server routes are modules written in .js files, that export functions corresponding to HTTP methods. Each function receives Express request and response objects as arguments, plus a next function. This is useful for creating a JSON API, for example.

There are three simple rules for naming the files that define your routes:

  • A file called src/routes/about.svelte corresponds to the /about route. A file called src/routes/blog/[slug].svelte corresponds to the /blog/:slug route, in which case params.slug is available to the route
  • The file src/routes/index.svelte (or src/routes/index.js) corresponds to the root of your app. src/routes/about/index.svelte is treated the same as src/routes/about.svelte.
  • Files and directories with a leading underscore do not create routes. This allows you to colocate helper modules and components with the routes that depend on them — for example you could have a file called src/routes/_helpers/datetime.js and it would not create a /_helpers/datetime route

static

The static directory contains any static assets that should be available. These are served using sirv.

In your service-worker.js file, you can import these as files from the generated manifest...

import { files } from '@sapper/service-worker';

...so that you can cache them (though you can choose not to, for example if you don't want to cache very large files).

Bundler config

Sapper uses Rollup or webpack to provide code-splitting and dynamic imports, as well as compiling your Svelte components. With webpack, it also provides hot module reloading. As long as you don't do anything daft, you can edit the configuration files to add whatever plugins you'd like.

CI/CD

I'm an automation advocate, I wrote a post about setting up the Github Actions Workflow for this blog.

The website is deployed to Netlify.

License

MIT

You can’t perform that action at this time.