diff --git a/website/src/components/SharedPatterns.tsx b/website/src/components/SharedPatterns.tsx index 4deab67e..bbd5cc8d 100644 --- a/website/src/components/SharedPatterns.tsx +++ b/website/src/components/SharedPatterns.tsx @@ -8,7 +8,7 @@ function PatternLink({ pattern }: { pattern: Tables<'code'> }) { // console.log('meta', meta); return ( - {meta.title || pattern.hash} by {meta.by.join(',') || 'Anonymous'} + {pattern.id}. {meta.title || pattern.hash} by {meta.by.join(',') || 'Anonymous'} ); } @@ -21,8 +21,18 @@ export function SharedPatterns() { 'https://pidxdsxphlhzjnzmifth.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM', ); - const { data: _publicPatterns } = await supabase.from('code').select().eq('public', true).limit(20); - const { data: _featuredPatterns } = await supabase.from('code').select().eq('featured', true).limit(20); + const { data: _publicPatterns } = await supabase + .from('code') + .select() + .eq('public', true) + .limit(20) + .order('id', { ascending: false }); + const { data: _featuredPatterns } = await supabase + .from('code') + .select() + .eq('featured', true) + .limit(20) + .order('id', { ascending: false }); setPublicPatterns(_publicPatterns); setFeaturedPatterns(_featuredPatterns); /* console.log('public', publicPatterns); diff --git a/website/src/repl/util.mjs b/website/src/repl/util.mjs index 81c41e9d..325417d7 100644 --- a/website/src/repl/util.mjs +++ b/website/src/repl/util.mjs @@ -90,10 +90,13 @@ export async function shareCode(codeToShare) { logger(`Link already generated!`, 'error'); return; } + const isPublic = confirm( + 'Do you want your pattern to be public? If no, press cancel and you will get just a private link.', + ); // generate uuid in the browser const hash = nanoid(12); const shareUrl = window.location.origin + window.location.pathname + '?' + hash; - const { data, error } = await supabase.from('code').insert([{ code: codeToShare, hash }]); + const { error } = await supabase.from('code').insert([{ code: codeToShare, hash, ['public']: isPublic }]); if (!error) { lastShared = codeToShare; // copy shareUrl to clipboard