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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌗 Remote CDN and theme button for the article theme #468

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever. I like it.


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
Loading