Skip to content

Commit

Permalink
Get app host from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Sep 18, 2021
1 parent b23f1fc commit cf20f27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ENCRYPTION_PASSWORD=s0m3r4nd0mstr1ng!w1thh1gh3ntr0pys0m3r4nd0mstr1ngw1thh1gh3ntr
# The usage is different from the values in giscus.json.
ORIGINS=["https://giscus.app", "https://giscus.vercel.app"]
ORIGINS_REGEX=["http://localhost:[0-9]+"]
NEXT_PUBLIC_GISCUS_APP_HOST_=https://giscus.app
5 changes: 3 additions & 2 deletions components/Configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { handleClipboardCopy } from '../lib/adapter';
import { useDebounce } from '../lib/hooks';
import { ICategory } from '../lib/types/adapter';
import { Theme } from '../lib/variables';
import { GISCUS_APP_HOST } from '../services/config';
import { getCategories } from '../services/giscus/categories';

interface IDirectConfig {
Expand Down Expand Up @@ -446,7 +447,7 @@ export default function Configuration({ directConfig, onDirectConfigChange }: IC
onChange={(event) => onDirectConfigChange('themeUrl', event.target.value as Theme)}
type="text"
className="my-2 px-[12px] py-[5px] min-w-[75%] sm:min-w-[50%] form-control border rounded-md placeholder-gray-500"
placeholder="https://giscus.app/themes/custom_example.css"
placeholder={`${GISCUS_APP_HOST}/themes/custom_example.css`}
/>

<p className="text-xs color-text-danger">
Expand All @@ -466,7 +467,7 @@ export default function Configuration({ directConfig, onDirectConfigChange }: IC
<pre>
<span className="pl-kos">{'<'}</span>
<span className="pl-ent">script</span> <span className="pl-c1">src</span>={'"'}
<span className="pl-s">https://giscus.app/client.js</span>
<span className="pl-s">{GISCUS_APP_HOST}/client.js</span>
{'"\n '}
<span className="pl-c1">data-repo</span>={'"'}
<span className="pl-s">{config.repository || '[ENTER REPO HERE]'}</span>
Expand Down
2 changes: 2 additions & 0 deletions services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export const GITHUB_REPO_INSTALLATION_URL = (repoWithOwner: string) =>

export const GITHUB_ACCESS_TOKEN_URL = (id: string) =>
`${GITHUB_INSTALLATIONS_URL}/${id}/access_tokens`;

export const GISCUS_APP_HOST = process.env.NEXT_PUBLIC_GISCUS_APP_HOST as string;

0 comments on commit cf20f27

Please sign in to comment.