Skip to content

Commit

Permalink
env: SELFHOSTED -> __SELFHOSTED
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumaus committed Nov 8, 2024
1 parent ff7ee1b commit 60c27f8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
4 changes: 2 additions & 2 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ADD package.json ./
FROM base as build

ENV NODE_ENV=production \
SELFHOSTED=true
__SELFHOSTED=true

RUN mkdir /app
WORKDIR /app
Expand All @@ -37,7 +37,7 @@ RUN npm run build
FROM base

ENV NODE_ENV=production \
SELFHOSTED=true
__SELFHOSTED=true

RUN mkdir /app
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion web/app/redux/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ const isStaging = isBrowser ? window.REMIX_ENV?.STAGING : process.env.STAGING
const STAGING_API_URL = isBrowser ? window.REMIX_ENV?.API_STAGING_URL : process.env.API_STAGING_URL
const PRODUCTION_API_URL = isBrowser ? window.REMIX_ENV?.API_URL : process.env.API_URL

export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.SELFHOSTED)
export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.__SELFHOSTED)

export const API_URL = isSelfhosted || !isStaging ? PRODUCTION_API_URL : STAGING_API_URL
export const AIAPI_URL = isBrowser ? window.REMIX_ENV?.AIAPI_URL : process.env.AIAPI_URL
Expand Down
2 changes: 1 addition & 1 deletion web/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
API_URL: process.env.API_URL,
API_STAGING_URL: process.env.API_STAGING_URL,
CDN_URL: process.env.CDN_URL,
SELFHOSTED: process.env.SELFHOSTED,
SELFHOSTED: process.env.__SELFHOSTED,
STAGING: process.env.STAGING,
PADDLE_CLIENT_SIDE_TOKEN: process.env.PADDLE_CLIENT_SIDE_TOKEN,
}
Expand Down
28 changes: 24 additions & 4 deletions web/app/routes/blog.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import type { MetaFunction } from '@remix-run/node'
import type { LoaderFunction, MetaFunction } from '@remix-run/node'
import { redirect } from '@remix-run/node'
import { Link, useLoaderData } from '@remix-run/react'
import { blogLoader } from 'utils/getPosts'
import _map from 'lodash/map'
import _isEmpty from 'lodash/isEmpty'
import _filter from 'lodash/filter'
import { TITLE_SUFFIX } from 'redux/constants'
import { isSelfhosted, TITLE_SUFFIX } from 'redux/constants'
import { getBlogPosts } from 'api'

export const loader = blogLoader
export const loader: LoaderFunction = async () => {
if (isSelfhosted) {
return redirect('/dashboard', 302)
}

const data = await getBlogPosts()
.then((data) => {
return data
})
.catch((error) => {
console.error(error)
})

if (!data || _isEmpty(data)) {
return null
}

return data
}

export const meta: MetaFunction = () => {
return [
Expand Down
19 changes: 1 addition & 18 deletions web/app/utils/getPosts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { marked, type Tokens } from 'marked'
import _isEmpty from 'lodash/isEmpty'
import { LoaderFunction } from '@remix-run/node'
import { getBlogPosts, getBlogPost, getBlogPostWithCategory } from 'api'
import { getBlogPost, getBlogPostWithCategory } from 'api'

const renderer = new marked.Renderer()

Expand Down Expand Up @@ -66,19 +65,3 @@ export async function getPost(slug: string, category?: string): Promise<IPost |
nickname: post.attributes?.nickname,
}
}

export const blogLoader: LoaderFunction = async () => {
const data = await getBlogPosts()
.then((data) => {
return data
})
.catch((error) => {
console.error(error)
})

if (!data || _isEmpty(data)) {
return null
}

return data
}
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"private": true,
"sideEffects": false,
"license": "AGPL-3.0",
"scripts": {
"build": "remix build",
"dev": "remix dev",
Expand Down

0 comments on commit 60c27f8

Please sign in to comment.