forked from jmug/cactoide
feat: add an option to remove the landing page
This commit is contained in:
@@ -13,3 +13,5 @@ DATABASE_URL="postgres://cactoide:cactoide_password@localhost:5432/cactoide_data
|
||||
APP_VERSION=latest
|
||||
PORT=3000
|
||||
HOSTNAME=0.0.0.0
|
||||
|
||||
PUBLIC_LANDING_INFO=true
|
||||
|
||||
2
.github/workflows/build-and-push.yml
vendored
2
.github/workflows/build-and-push.yml
vendored
@@ -60,6 +60,8 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
build-args: |
|
||||
PUBLIC_LANDING_INFO=${{ vars.PUBLIC_LANDING_INFO }}
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
|
||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -28,6 +28,8 @@ jobs:
|
||||
|
||||
- name: Build application
|
||||
run: npm run build
|
||||
env:
|
||||
PUBLIC_LANDING_INFO: ${{ vars.PUBLIC_LANDING_INFO }}
|
||||
|
||||
- name: Test build output
|
||||
run: |
|
||||
|
||||
10
Dockerfile
10
Dockerfile
@@ -2,26 +2,28 @@ FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json .
|
||||
|
||||
RUN npm ci
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
ARG PUBLIC_LANDING_INFO
|
||||
ENV PUBLIC_LANDING_INFO=$PUBLIC_LANDING_INFO
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
RUN npm prune --production
|
||||
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/build build/
|
||||
COPY --from=builder /app/node_modules node_modules/
|
||||
COPY package.json .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/healthz || exit 1
|
||||
|
||||
EXPOSE 3000
|
||||
CMD [ "node", "build" ]
|
||||
|
||||
13
README.md
13
README.md
@@ -55,7 +55,18 @@ Your app will be available at `http://localhost:5173`. You can use the Makefile
|
||||
|
||||
Use the `database/seed.sql` if you want to populate your database with dummy data.
|
||||
|
||||
### i18n
|
||||
### Options
|
||||
|
||||
#### 1. Landing page option
|
||||
|
||||
Supports a conditional landing page display based on the `PUBLIC_LANDING_INFO` environment variable. If you don't want to show your users the cactoide landing page, just use the `PUBLIC_LANDING_INFO=false` variable. This will automatically remove the landing home page and redirect users to the `/discover` page.
|
||||
|
||||
This is useful for:
|
||||
|
||||
- Creating a minimal discovery-focused experience
|
||||
- Customizing the user journey based on deployment environment
|
||||
|
||||
#### 2. i18n
|
||||
|
||||
There is no proper i18n implemented, we have an `/i18n` folder with specific languages. To use an existing translation, just rename the language code JSON file to `messages.json` and you are ready to go. If you would like to add a new translation (which is really appreciated), just create a new `<language_code>.json` file and add the translations from the `messages.json`.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "cactoide",
|
||||
"private": true,
|
||||
"version": "0.0.3",
|
||||
"version": "0.1.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { t } from '$lib/i18n/i18n.js';
|
||||
import { PUBLIC_LANDING_INFO } from '$env/static/public';
|
||||
|
||||
// Check if current page is active
|
||||
const isActive = (path: string): boolean => {
|
||||
@@ -24,12 +25,14 @@
|
||||
|
||||
<!-- Navigation -->
|
||||
<div class="md:flex md:items-center md:space-x-8">
|
||||
{#if PUBLIC_LANDING_INFO !== 'false'}
|
||||
<button
|
||||
on:click={() => goto('/')}
|
||||
class={isActive('/') ? 'text-violet-400' : 'cursor-pointer'}
|
||||
>
|
||||
{t('navigation.home')}
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
on:click={() => goto('/discover')}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import Navbar from '$lib/components/Navbar.svelte';
|
||||
import { t } from '$lib/i18n/i18n.js';
|
||||
|
||||
let { data } = $props();
|
||||
let { data, children } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<!-- Main content -->
|
||||
<main class="relative z-10">
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
|
||||
11
src/routes/+page.server.ts
Normal file
11
src/routes/+page.server.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { PUBLIC_LANDING_INFO } from '$env/static/public';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
if (PUBLIC_LANDING_INFO === 'false') {
|
||||
throw redirect(302, '/discover');
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
Reference in New Issue
Block a user