Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
KeyPress
https://github.com/zernonia/keypress
Admin
KeyPress - an open-source blogging platform + free custom domains.
Tokens:
723
Snippets:
4
Trust Score:
9.3
License:
MIT
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Shell Script for Installing Dependencies Source: https://github.com/zernonia/keypress/blob/main/README.md A series of shell commands to set up the development environment for the KeyPress project. This includes installing Yarn globally, cloning the repository, installing NPM packages, and starting the local development server. ```shell npm install --global yarn git clone https://github.com/zernonia/keypress.git cd keypress yarn install yarn dev ``` -------------------------------- ### Supabase Database Schema for KeyPress Source: https://github.com/zernonia/keypress/blob/main/README.md Defines the SQL schema for the Supabase database used by KeyPress. It includes tables for domains, profiles, and posts, along with a view for tags and a trigger function to handle new user creation. ```sql create table domains ( user_id uuid, url text not null primary key, active boolean, created_at timestamp default now() ); create table profiles ( id uuid default uuid_generate_v4() primary key, username text, avatar_url text, name text, created_at timestamp default now(), subdomain text references domains (url) ); create table posts ( id uuid default uuid_generate_v4() primary key, author_id uuid references profiles (id), created_at timestamp default now(), slug text not null, title text, body text, cover_img text, active boolean, tags ARRAY, featured boolean not null ); create or replace view tags_view as select *, count(*) from (select unnest(tags) as name from posts where active is true) s group by name; create or replace function public.handle_new_user() returns trigger as $$ begin insert into public.profiles (id, avatar_url, username, name) values (new.id, new.raw_user_meta_data->>'avatar_url', new.raw_user_meta_data->>'user_name', new.raw_user_meta_data->>'preferred_username'); return new; end; $$ language plpgsql security definer; create trigger on_auth_user_created after insert on auth.users for each row execute procedure public.handle_new_user(); ``` -------------------------------- ### Nuxt 3 Dynamic Route Mapping Source: https://github.com/zernonia/keypress/blob/main/README.md This configuration file for Nuxt 3's router options allows for dynamic mapping of new routes based on the SSR context, specifically handling user-defined subdomains to navigate to the correct content. ```typescript import type { RouteRecordRaw } from 'vue-router'; export default { routes: (_routes: RouteRecordRaw[]) => { const { ssrContext } = useNuxtApp(); if (ssrContext?.user?.subdomain) { return [ { name: 'user-siteId', path: '/', component: () => import('~/pages/user/[siteId].vue'), }, ]; } return _routes; }, } ``` -------------------------------- ### Nuxt 3 Subdomain Routing Middleware Source: https://github.com/zernonia/keypress/blob/main/README.md This middleware in Nuxt 3 is responsible for detecting the current domain and setting the SSR context. It plays a crucial role in handling multi-tenant routing based on subdomains. ```typescript export default defineNuxtRouteMiddleware((to, from) => { const subdomain = to.host?.split('.')[0]; if (subdomain) { const { ssrContext } = useNuxtApp(); ssrContext.user = { subdomain }; } }) ```