- Go to api folder
- Select the collection you want to add the slug to
- Go to config folder
- Open
routes.json
- Add this code to
routes
array:{ "method": "GET", "path": "/collection/:slug", "handler": "collection.findOne",
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { supabase } from '$lib/database'; | |
import { readable, get } from 'svelte/store'; | |
const posts = readable(null, (set) => { | |
supabase | |
.from('posts') | |
.select('*') | |
.then(({ data }) => set(data)); | |
const subscriptions = supabase | |
.from('posts') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createClient } from '@supabase/supabase-js'; | |
const supabase = createClient( | |
import.meta.env.VITE_SUPABASE_URL.toString(), | |
import.meta.env.VITE_SUPABASE_KEY.toString() | |
); | |
export default supabase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
indexes = [] # 0, 6, 9 | 20 | |
for i, item in enumerate(items): | |
if i == 0: | |
indexes.append(i) | |
continue | |
if i+1 == len(items): | |
break | |
if item[1] != items[i+1][1]: | |
indexes.append(i+1) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="module"> | |
/** @type {import('@sveltejs/kit').ErrorLoad} */ | |
export function load({ error, status }) { | |
return { | |
props: { | |
status: status, | |
message: error.message | |
} | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="module"> | |
export async function load({ page, params, fetch, session, stuff }) { | |
const slug = page.params.slug; | |
const url = `http://localhost:1337/categories/${slug}`; | |
const res = await fetch(url); | |
const category = await res.json(); | |
return { | |
props: { | |
category | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let array = [0, 1, 3, 4, 5]; | |
let item = 3; | |
console.log(array); | |
const index = array.indexOf(item); | |
if (index > -1) { | |
array.splice(index, 1); | |
} | |
console.log(array); |