Skip to content

Commit

Permalink
🌗 Remote CDN and theme button for the article theme (#468)
Browse files Browse the repository at this point in the history
Co-authored-by: Rowan Cockett <[email protected]>
  • Loading branch information
agahkarakuzu and rowanc1 authored Sep 13, 2024
1 parent 8233483 commit 2cb619f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/nice-suns-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@myst-theme/article": patch
"@myst-theme/book": patch
---

Remote CDN and theme button for the article theme
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ To run on a specific port (for example, developing locally between two projects)
myst start --headless --server-port 3111
CONTENT_CDN_PORT=3111 npm run theme:book
```
To connect to a remote content server, set the `CONTENT_CDN` environment variable:

```bash
CONTENT_CDN=https://remote.example.com npm run theme:book
CONTENT_CDN=https://remote.example.com npm run theme:article
```

## Deployment

Expand Down
4 changes: 4 additions & 0 deletions themes/article/app/components/ArticlePageAndNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { GridSystemProvider, TabStateProvider, UiStateProvider } from '@myst-theme/providers';
import { ThemeButton } from '@myst-theme/site';

export function ArticlePageAndNavigation({ children }: { children: React.ReactNode }) {
return (
<UiStateProvider>
<TabStateProvider>
<GridSystemProvider gridSystem="article-left-grid">
<div className="fixed top-4 right-4 z-50">
<ThemeButton />
</div>
<article className="article content article-left-grid subgrid-gap">{children}</article>
</GridSystemProvider>
</TabStateProvider>
Expand Down
2 changes: 1 addition & 1 deletion themes/article/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { responseNoArticle, responseNoSite, getDomainFromRequest } from '@myst-theme/site';

const CONTENT_CDN_PORT = process.env.CONTENT_CDN_PORT ?? '3100';
const CONTENT_CDN = `http://localhost:${CONTENT_CDN_PORT}`;
const CONTENT_CDN = process.env.CONTENT_CDN ?? `http://localhost:${CONTENT_CDN_PORT}`;

export async function getConfig(): Promise<SiteManifest> {
const url = `${CONTENT_CDN}/config.json`;
Expand Down
2 changes: 1 addition & 1 deletion themes/book/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { redirect } from '@remix-run/node';
import { responseNoArticle, responseNoSite, getDomainFromRequest } from '@myst-theme/site';

const CONTENT_CDN_PORT = process.env.CONTENT_CDN_PORT ?? '3100';
const CONTENT_CDN = `http://localhost:${CONTENT_CDN_PORT}`;
const CONTENT_CDN = process.env.CONTENT_CDN ?? `http://localhost:${CONTENT_CDN_PORT}`;

export async function getConfig(): Promise<SiteManifest> {
const url = `${CONTENT_CDN}/config.json`;
Expand Down

0 comments on commit 2cb619f

Please sign in to comment.