sapper

Sapper event for route change

徘徊边缘 提交于 2020-01-25 06:47:32
问题 I need to redirect users to login page if they are not authenticated. I need something like route.beforeEach in Vue.js, ideally: sapper.beforeRouteChange((to, from, next) => { const isAuth = "[some session or token check]"; if (!isAuth) { next('/login') } next() }) I found Sapper - protected routes (route guard) this question but I think it's not enough for my needs. What if token or auth changes in runtime? OR is it covered by reactivity? Edit 1: I think that this issue on Sapper GitHub

How do I add categories or tags to a Svelte/Sapper markdown site?

隐身守侯 提交于 2020-01-16 09:47:03
问题 Forking this question off from Sapper/Svelte: How do I add markdown files? to help future searchers: I see that all the posts will have a link right after the Top-Level Domain Ex www.example.com/post1 , www.example.com/post2 . But what if someone using the template wants to categorize the posts. Ex www.example.com/svelte-posts/post1 , www.example.com/vuejs-posts/post1 回答1: If you want traditional WordPress-style categories I would add that to the markdown front matter of the posts (Jekyll

Sapper - protected routes (route guard)

早过忘川 提交于 2019-12-24 21:40:10
问题 My question is very simple. How do you prevent, e.g. non authorized user, to enter specific routes in sapper? user.svelte <script> import { onMount } from 'svelte'; onMount(() => { if(!authenticated) window.history.back() }); </script> Is there any option to run some code before mounting to the DOM? How do you solve this kind of problem? Thank you. 回答1: I can't say it's the right thing. It's what I do in my SPAs. If I want to protect all routes of my app. I create following in _layout.svelte

now-cli deployment doesn't build package.json dependencies

巧了我就是萌 提交于 2019-12-22 18:48:14
问题 I'm trying to deploy a Sapper built application via @now-node . The task is basically to deploy a Polka server with dependencies and to serve static/ and client/ files statically. I have managed to include the files that Lambda requires via includeFiles but now I see in the logs that the builder ignores dependencies described in package.json. The exact message is Starting server on port 3000 Cannot find module 'sirv' Did you forget to add it to "dependencies" in `package.json`? But I see in

fetch post is giving me undefined for the posted data?

好久不见. 提交于 2019-12-11 18:48:26
问题 Learning how to use Sapper. I have a component with form (the form has one field to enter an email address) and use fetch to post the data to the serverhandle. When I post the data and try to log the data I posted, it logs Undefined. I have no idea why and need help to figure it out. Here is my component with the form and fetch post code: <script> let emailvalue let url = "posthandle" async function handleSubmit(event) { console.log(event); console.log(event.target); emailvalue = event.target

Sapper/Svelte: How do I add markdown files?

☆樱花仙子☆ 提交于 2019-12-08 06:41:14
问题 I am creating a blog using Sapper using the default sapper-template-rollup. In the blog folder, it does mention about generating data from markdown files. But I can't find how to do it? 回答1: You may find this repo helpful. I also have an open PR on the Sapper Template repo, first revising the old Markdown branch in Jan. 2019 and then adding Svelte 3 support in May 2019, but it is probably easier to look at and clone my repo on GitLab, plus it has more current dependency updates I have not

Sapper/Svelte: How do I add markdown files?

巧了我就是萌 提交于 2019-12-06 16:07:34
I am creating a blog using Sapper using the default sapper-template-rollup . In the blog folder, it does mention about generating data from markdown files. But I can't find how to do it? You may find this repo helpful. I also have an open PR on the Sapper Template repo, first revising the old Markdown branch in Jan. 2019 and then adding Svelte 3 support in May 2019, but it is probably easier to look at and clone my repo on GitLab , plus it has more current dependency updates I have not added to the PR yet. You might have more lick using MDsveX which is a Svelte Markdown processor, created by

now-cli deployment doesn't build package.json dependencies

自闭症网瘾萝莉.ら 提交于 2019-12-06 09:44:28
I'm trying to deploy a Sapper built application via @now-node . The task is basically to deploy a Polka server with dependencies and to serve static/ and client/ files statically. I have managed to include the files that Lambda requires via includeFiles but now I see in the logs that the builder ignores dependencies described in package.json. The exact message is Starting server on port 3000 Cannot find module 'sirv' Did you forget to add it to "dependencies" in `package.json`? But I see in the build log that dependencies are not collected. Both package.json and package-lock.json are present