Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殽 allow CONTENT_CDN host to be spec'ed #346

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/serious-beds-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@myst-theme/article': patch
'@myst-theme/book': patch
---

Theme now looks to CONTENT_CDN_HOST for static url re-writing
7 changes: 6 additions & 1 deletion themes/article/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import {
} from '@myst-theme/common';
import { responseNoArticle, responseNoSite, getDomainFromRequest } from '@myst-theme/site';

const CONTENT_CDN_HOST =
process.env.CONTENT_CDN_HOST && process.env.CONTENT_CDN_HOST.startsWith('http')
? new URL(process.env.CONTENT_CDN_HOST).hostname
: process.env.CONTENT_CDN_HOST ?? 'localhost';
const CONTENT_CDN_PORT = process.env.CONTENT_CDN_PORT ?? '3100';
const CONTENT_CDN = `http://localhost:${CONTENT_CDN_PORT}`;
const CONTENT_CDN = `http://${CONTENT_CDN_HOST}:${CONTENT_CDN_PORT}`;

export async function getConfig(): Promise<SiteManifest> {
const url = `${CONTENT_CDN}/config.json`;
Expand All @@ -34,6 +38,7 @@ function updateLink(url: string) {
if (process.env.MODE === 'static') {
return `/myst_assets_folder${url}`;
}
console.log('rewriting:', url, `${CONTENT_CDN}${url}`);
stevejpurves marked this conversation as resolved.
Show resolved Hide resolved
return `${CONTENT_CDN}${url}`;
}

Expand Down
7 changes: 6 additions & 1 deletion themes/book/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import {
import { redirect } from '@remix-run/node';
import { responseNoArticle, responseNoSite, getDomainFromRequest } from '@myst-theme/site';

const CONTENT_CDN_HOST =
process.env.CONTENT_CDN_HOST && process.env.CONTENT_CDN_HOST.startsWith('http')
? new URL(process.env.CONTENT_CDN_HOST).hostname
: process.env.CONTENT_CDN_HOST ?? 'localhost';
const CONTENT_CDN_PORT = process.env.CONTENT_CDN_PORT ?? '3100';
const CONTENT_CDN = `http://localhost:${CONTENT_CDN_PORT}`;
const CONTENT_CDN = `http://${CONTENT_CDN_HOST}:${CONTENT_CDN_PORT}`;

export async function getConfig(): Promise<SiteManifest> {
const url = `${CONTENT_CDN}/config.json`;
Expand All @@ -34,6 +38,7 @@ function updateLink(url: string) {
if (process.env.MODE === 'static') {
return `/myst_assets_folder${url}`;
}
console.log('rewriting:', url, `${CONTENT_CDN}${url}`);
stevejpurves marked this conversation as resolved.
Show resolved Hide resolved
return `${CONTENT_CDN}${url}`;
}

Expand Down