Skip to content

Commit 8c5b367

Browse files
authored
Merge pull request #39 from khaykingleb/supabase-integration
Supabase integration
2 parents 7c5dfb4 + 2722aed commit 8c5b367

25 files changed

+862
-163
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SUPABASE_URL=http://127.0.0.1:54321
2+
SUPABASE_ANON_KEY=
3+
SUPABASE_SERVICE_ROLE_KEY=

.envrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file is used by direnv to automatically load environment variables
2+
# from the .env file whenever you enter this directory.
3+
4+
# To ensure security, direnv requires you to explicitly allow the execution
5+
# of this file by running 'direnv allow' after any changes.
6+
# This prevents unauthorized scripts from being executed automatically.
7+
8+
dotenv

.github/workflows/release.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,22 @@ jobs:
3434
run: npx semantic-release
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
37+
38+
deploy:
39+
needs: release
40+
runs-on: ubuntu-latest
41+
env:
42+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
43+
PROJECT_ID: ${{ secrets.PROJECT_ID }}
44+
steps:
45+
- name: Checkout code so that it is available to use in the executing runner
46+
uses: actions/[email protected]
47+
with:
48+
fetch-depth: 0
49+
50+
- uses: supabase/setup-cli@v1
51+
with:
52+
version: latest
53+
54+
- name: Deploy
55+
run: supabase functions deploy --project-ref ${{ env.PROJECT_ID }}

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
# Node
12
node_modules
2-
/.cache
33
/build
4-
.env
54

5+
# Terraform
66
terraform.tfstate
77
terraform.tfstate.backup
88
terraform.tfvars
99
.terraform
1010

11+
# Supabase
12+
supabase/volumes/db/data
13+
14+
# Misc
15+
.env
1116
.DS_Store
17+
.vscode/

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ repos:
5959
hooks:
6060
- id: cspell
6161

62+
- repo: https://github.com/sqlfluff/sqlfluff
63+
rev: 3.3.0
64+
hooks:
65+
- id: sqlfluff-lint
66+
args:
67+
- "--dialect=postgres"
68+
- id: sqlfluff-fix
69+
args:
70+
- "--dialect=postgres"
71+
6272
- repo: https://github.com/antonbabenko/pre-commit-terraform
6373
rev: v1.94.1
6474
hooks:

.secrets.baseline

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
{
110110
"path": "detect_secrets.filters.regex.should_exclude_file",
111111
"pattern": [
112-
"pnpm-lock.yaml"
112+
"pnpm-lock.yaml",
113+
"supabase/config.toml"
113114
]
114115
}
115116
],

.tool-versions

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
direnv 2.35.0
2+
pre-commit 3.7.0
13
nodejs 21.7.3
24
pnpm 9.9.0
35
yarn 1.22.22
6+
supabase-cli 2.1.1
47
terraform 1.5.4
5-
pre-commit 3.7.0

Makefile

Lines changed: 113 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,192 @@
1-
SHELL := /bin/bash
21
.DEFAULT_GOAL = help
2+
SHELL := /bin/bash
3+
VENDOR_DIR := vendor/react-notion-x
34

4-
##@ Repo Initialization
5+
# Load environment variables from .env
6+
ifneq (,$(wildcard ./.env))
7+
include .env
8+
export
9+
endif
510

6-
prerequisite: ## Install prerequisite tools
11+
##=============================================================================
12+
##@ Repo Initialization
13+
##=============================================================================
14+
15+
PLUGINS := \
16+
direnv https://github.com/asdf-community/asdf-direnv.git \
17+
pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git \
18+
nodejs https://github.com/asdf-vm/asdf-nodejs.git \
19+
pnpm https://github.com/jonathanmorley/asdf-pnpm.git \
20+
yarn https://github.com/twuni/asdf-yarn.git \
21+
supabase-cli https://github.com/gavinying/asdf-supabase-cli.git \
22+
terraform https://github.com/asdf-community/asdf-hashicorp.git
23+
24+
prerequisites: ## Install prerequisite tools
725
@echo "Checking and installing required plugins."
8-
@plugins=( \
9-
"terraform https://github.com/asdf-community/asdf-hashicorp.git" \
10-
"pnpm https://github.com/jonathanmorley/asdf-pnpm.git" \
11-
"yarn https://github.com/twuni/asdf-yarn.git" \
12-
"nodejs https://github.com/asdf-vm/asdf-nodejs.git" \
13-
"pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git" \
14-
); \
15-
for info in "$${plugins[@]}"; do \
16-
read plugin url <<< "$$info"; \
26+
@echo "${PLUGINS}" | tr ' ' '\n' | paste - - | while read -r plugin url; do \
1727
if asdf plugin-list | grep -q $$plugin; then \
1828
echo "Plugin '$$plugin' is already installed."; \
1929
else \
2030
echo "Adding plugin '$$plugin'."; \
2131
asdf plugin-add $$plugin $$url; \
2232
fi; \
23-
done;
33+
done
2434
@echo "Installing specified versions."
2535
asdf install
2636
@echo "Currently installed versions:"
2737
asdf current
28-
.PHONY: prerequisite
38+
.PHONY: prerequisites
39+
40+
env: ## Create .env file if it doesn't exist
41+
@if ! [ -e .env ]; then \
42+
cp .env.example .env; \
43+
echo "Created .env file. Please edit it according to your setup."; \
44+
fi
45+
.PHONY: env
2946

3047
deps-notion: ## Install dependencies for react-notion-x
3148
@echo "Installing dependencies for react-notion-x."
32-
git submodule update --init --recursive
33-
cd vendor/react-notion-x && yarn install --frozen-lockfile
34-
.PHONY: notion-deps
49+
@git submodule update --init --recursive
50+
@cd ${VENDOR_DIR} && yarn install --frozen-lockfile
51+
.PHONY: deps-notion
3552

3653
deps: deps-notion ## Install repo dependencies
3754
@echo "Installing dependencies."
38-
pnpm install
55+
@pnpm install
3956
.PHONY: deps
4057

4158
deps-prod: deps-notion ## Install production dependencies
4259
@echo "Installing production dependencies."
43-
pnpm install --frozen-lockfile
60+
@pnpm install --frozen-lockfile
4461
.PHONY: deps-prod
4562

4663
pre-commit: ## Install pre-commit hooks
4764
@echo "Installing pre-commit hooks."
48-
pre-commit install -t pre-commit -t commit-msg
65+
@pre-commit install -t pre-commit -t commit-msg
66+
.PHONY: pre-commit
4967

50-
init: prerequisite deps pre-commit ## Initialize local environment for development
68+
init: prerequisites env deps pre-commit ## Initialize local environment for development
5169
.PHONY: init
5270

71+
##=============================================================================
5372
##@ Scripts
73+
##=============================================================================
5474

5575
build-notion: ## Build react-notion-x
5676
@echo "Building react-notion-x."
57-
cd vendor/react-notion-x && yarn build
77+
@cd ${VENDOR_DIR} && yarn build
5878
.PHONY: build-notion
5979

6080
build: build-notion ## Build project
6181
@echo "Building project."
62-
pnpm run build
82+
@pnpm run build
6383
.PHONY: build
6484

6585
run-dev: ## Run development server
6686
@echo "Running development server."
67-
pnpm run dev
87+
@pnpm run dev
6888
.PHONY: run-dev
6989

7090
run-prod: build ## Run production server
7191
@echo "Starting server."
72-
pnpm run start
92+
@pnpm run start
7393
.PHONY: run-prod
7494

7595
lint: ## Lint project
7696
@echo "Linting project."
77-
pnpm run lint && pnpm run stylelint && pnpm run typecheck
97+
@pnpm run lint && pnpm run stylelint && pnpm run typecheck
7898
.PHONY: lint
7999

80100
format: ## Format project
81101
@echo "Formatting project."
82-
pnpm run format
102+
@pnpm run format
83103
.PHONY: format
84104

105+
##=============================================================================
106+
##@ Supabase
107+
##=============================================================================
108+
109+
supabase-start: ## Start supabase containers
110+
@echo "Starting supabase."
111+
@supabase start
112+
.PHONY: supabase-start
113+
114+
supabase-status: ## Check supabase status
115+
@echo "Checking supabase status."
116+
@supabase status
117+
.PHONY: supabase-status
118+
119+
supabase-reset: ## Reset supabase database (runs migrations and seeds)
120+
@echo "Resetting supabase database."
121+
@supabase db reset
122+
.PHONY: supabase-reset
123+
124+
supabase-migration-%: ## Create supabase migration
125+
@echo "Creating custom migration: supabase/migrations/some_timestamp_$*.sql"
126+
@supabase db diff --use-migra -f $*
127+
.PHONY: supabase-migration-%
128+
129+
supabase-generate-types: ## Generate supabase types
130+
@echo "Generating supabase types."
131+
@supabase gen types typescript --local > app/integrations/supabase/database.types.ts
132+
.PHONY: supabase-generate-types
133+
134+
supabase-stop: ## Stop supabase containers
135+
@echo "Stopping supabase."
136+
@supabase stop
137+
.PHONY: supabase-stop
138+
139+
#==============================================================================
140+
##@ Ngrok
141+
##==============================================================================
142+
85143
ngrok-dev: ## Run ngrok for development server
86144
@echo "Running ngrok."
87-
ngrok http 5173
145+
@ngrok http 5173
88146
.PHONY: ngrok-dev
89147

90148
ngrok-prod: ## Run ngrok for production server
91149
@echo "Running ngrok."
92-
ngrok http 3000
150+
@ngrok http 55203
93151
.PHONY: ngrok-prod
94152

95-
##@ Miscullaneous
153+
#==============================================================================
154+
##@ Security
155+
##==============================================================================
96156

97-
create-secrets-baseline: ## Create secrets baseline file
98-
detect-secrets scan > .secrets.baseline
157+
create-secrets-baseline: ## Create secrets baseline file
158+
@detect-secrets scan > .secrets.baseline
99159
.PHONY: create-secrets-baseline
100160

101-
audit-secrets-baseline: ## Check updated .secrets.baseline file
102-
detect-secrets audit .secrets.baseline
103-
git commit .secrets.baseline --no-verify -m "build(security): update secrets.baseline"
161+
audit-secrets-baseline: ## Check updated .secrets.baseline file
162+
@detect-secrets audit .secrets.baseline
104163
.PHONY: audit-secrets-baseline
105164

106-
update-pre-commit-hooks: ## Update pre-commit hooks
107-
pre-commit autoupdate
165+
detect-secrets: ## Scan for secrets
166+
@detect-secrets scan --baseline .secrets.baseline
167+
.PHONY: detect-secrets
168+
169+
##=============================================================================
170+
##@ Miscellaneous
171+
##=============================================================================
172+
173+
update-pre-commit-hooks: ## Update pre-commit hooks
174+
@pre-commit autoupdate
108175
.PHONY: update-pre-commit-hooks
109176

110177
clean: ## Clean project
111178
@echo "Cleaning project."
112-
rm -rf node_modules build
113-
find vendor/react-notion-x -type d -name 'build' -exec rm -rf {} +
114-
find vendor/react-notion-x -type d -name 'node_modules' -exec rm -rf {} +
179+
@rm -rf node_modules build
180+
@find ${VENDOR_DIR} -type d -name 'build' -exec rm -rf {} +
181+
@find ${VENDOR_DIR} -type d -name 'node_modules' -exec rm -rf {} +
115182
.PHONY: clean
116183

184+
##=============================================================================
117185
##@ Helper
186+
##=============================================================================
118187

119-
help: ## Display help
120-
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage: \033[36m\033[0m\n"} /^[a-zA-Z\.\%-]+:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
188+
help: ## Display help
189+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} \
190+
/^[a-zA-Z_-]+%?:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 } \
191+
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
121192
.PHONY: help

app/components/organisms/Carousel.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
import { Link } from "@remix-run/react";
22

3-
import { Post } from "~/data/posts";
3+
import { Tables } from "~/integrations/supabase/database.types";
44

55
/**
66
* Carousel component to display a list of posts
77
*
8-
* @param items - Array of post items to display
8+
* @param posts - Array of post items to display
99
* @returns Carousel component
1010
*/
11-
export const Carousel = ({ items }: { items: Post[] }) => {
11+
export const Carousel = ({ posts }: { posts: Tables<"posts">[] }) => {
1212
return (
1313
<div className="mb-2 mt-2">
14-
{items.length > 0 ? (
14+
{posts.length > 0 ? (
1515
<div className="carousel carousel-vertical h-full w-full">
16-
{items.map((item) => (
16+
{posts.map((post) => (
1717
<Link
18-
to={`/blog/${item.slug}`}
19-
key={item.id}
18+
to={`/blog/${post.slug}`}
19+
key={post.id}
2020
className="carousel-item block w-full cursor-pointer transition-all duration-300 hover:bg-gray-100"
2121
>
2222
<div className="flex w-full items-center p-3">
2323
<div className="flex-grow">
2424
<h2 className="font-gill-sans mb-1 text-base font-semibold sm:text-base">
25-
{item.title}
25+
{post.title}
2626
</h2>
2727
<p className="font-gill-sans mb-1 text-sm">
28-
Created at {item.publishDate.replace(/-/g, "/")}
28+
Created at{" "}
29+
{new Date(post.created_at).toLocaleDateString("en-US", {
30+
year: "numeric",
31+
month: "numeric",
32+
day: "numeric",
33+
})}
2934
</p>
3035
<div className="font-gill-sans">
31-
{item.tags.map((tag) => (
36+
{post.tags.map((tag) => (
3237
<span
3338
key={tag}
3439
className="badge badge-ghost ml-[-0.2rem] mr-1 bg-blue-100 bg-opacity-50 px-1.5 py-0.5 text-xs"
@@ -39,8 +44,8 @@ export const Carousel = ({ items }: { items: Post[] }) => {
3944
</div>
4045
</div>
4146
<img
42-
src={item.imageUrl}
43-
alt={item.title}
47+
src={post.image_url}
48+
alt={post.title}
4449
className="h-28 w-auto"
4550
/>
4651
</div>

0 commit comments

Comments
 (0)