Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion packages/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ export function updateSiteManifestStaticLinksInplace(
if (data.options.logo) data.options.logo = updateUrl(data.options.logo);
if (data.options.logo_dark) data.options.logo_dark = updateUrl(data.options.logo_dark);
if (data.options.favicon) data.options.favicon = updateUrl(data.options.favicon);
if (data.options.style) data.options.style = updateUrl(data.options.style);
if (data.options.style) {
// `style` may be a single link or, for a `multiple` file option, a list.
data.options.style = Array.isArray(data.options.style)
? data.options.style.map(updateUrl)
: updateUrl(data.options.style);
}
if (data.parts) {
Object.values(data.parts).forEach(({ mdast }) => {
updateMdastStaticLinksInplace(mdast, updateUrl);
Expand Down
21 changes: 15 additions & 6 deletions themes/article/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,21 @@ export async function getFavicon(): Promise<{
export async function getCustomStyleSheet(): Promise<string | undefined> {
// We are always fetching this at run time, so we don't want the rewritten links
const config = await getConfig({ rewriteStaticFolder: false });
const url = config.options?.style;
if (!url) {
// `style` may be a single URL or, since the option is declared `multiple`, a
// list of them. Normalize to an array, fetch each, and concatenate in order
// so later stylesheets override earlier ones.
const style = config.options?.style;
const urls = (Array.isArray(style) ? style : [style]).filter(Boolean);
if (urls.length === 0) {
return;
}
const response = await fetch(url).catch(() => null);
if (!response || response.status === 404) return;
const css = await response.text();
return css;
const sheets = await Promise.all(
urls.map(async (url) => {
const response = await fetch(url).catch(() => null);
if (!response || response.status === 404) return undefined;
return response.text();
}),
);
Comment thread
parmentelat marked this conversation as resolved.
const css = sheets.filter(Boolean).join('\n\n');
return css || undefined;
}
3 changes: 2 additions & 1 deletion themes/article/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ options:
Supports wildcard subdomains with *. Example: "jupyter.org" or "*.jupyter.org"
- type: file
id: style
description: Local path to a CSS file
multiple: true
description: Local path to a CSS file, or a list of them (applied in order)
Comment thread
parmentelat marked this conversation as resolved.
Outdated
build:
install: npm ci --ignore-scripts
start: npm run start
Expand Down
21 changes: 15 additions & 6 deletions themes/book/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,21 @@ export async function getFavicon(): Promise<{
export async function getCustomStyleSheet(): Promise<string | undefined> {
Comment thread
parmentelat marked this conversation as resolved.
// We are always fetching this at run time, so we don't want the rewritten links
const config = await getConfig({ rewriteStaticFolder: false });
const url = config.options?.style;
if (!url) {
// `style` may be a single URL or, since the option is declared `multiple`, a
// list of them. Normalize to an array, fetch each, and concatenate in order
// so later stylesheets override earlier ones.
const style = config.options?.style;
const urls = (Array.isArray(style) ? style : [style]).filter(Boolean);
if (urls.length === 0) {
return;
}
const response = await fetch(url).catch(() => null);
if (!response || response.status === 404) return;
const css = await response.text();
return css;
const sheets = await Promise.all(
urls.map(async (url) => {
const response = await fetch(url).catch(() => null);
if (!response || response.status === 404) return undefined;
return response.text();
}),
);
Comment thread
parmentelat marked this conversation as resolved.
const css = sheets.filter(Boolean).join('\n\n');
return css || undefined;
}
3 changes: 2 additions & 1 deletion themes/book/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ options:
Supports wildcard subdomains with *. Example: "jupyter.org" or "*.jupyter.org"
- type: file
id: style
description: Local path to a CSS file
multiple: true
description: Local path to a CSS file, or a list of them (applied in order)
Comment thread
parmentelat marked this conversation as resolved.
Outdated
parts:
- id: footer
description: The site wide footer
Expand Down
Loading