-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔢 Support numbered references (#370)
- Loading branch information
Showing
13 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'myst-to-react': patch | ||
'@myst-theme/article': patch | ||
'@myst-theme/site': patch | ||
'@myst-theme/book': patch | ||
'@myst-theme/styles': patch | ||
--- | ||
|
||
Support numbered references |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export type ThemeCssOptions = { | ||
numbered_references?: boolean; | ||
}; | ||
|
||
type MystThemeVariables = { | ||
'cite-group-open'?: '(' | '[' | string; | ||
'cite-group-close'?: ')' | ']' | string; | ||
}; | ||
|
||
function variables(vars: MystThemeVariables) { | ||
const css = Object.entries(vars) | ||
.map(([name, value]) => `--${name}: '${value}';`) | ||
.join('\n '); | ||
if (!css) return ''; | ||
return `:root {\n ${css}}`; | ||
} | ||
|
||
export function themeCSS(options?: ThemeCssOptions) { | ||
const numbered_references = !!options?.numbered_references; | ||
const citationCss = numbered_references | ||
? { 'cite-group-open': '[', 'cite-group-close': ']' } | ||
: {}; | ||
return variables({ ...citationCss }); | ||
} | ||
|
||
export function cssResponse(css: string): Response { | ||
return new Response(css, { | ||
headers: { | ||
'Content-Type': 'text/css', | ||
'Cache-Control': 'no-cache', | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ export const links: LinksFunction = () => { | |
}, | ||
{ rel: 'stylesheet', href: tailwind }, | ||
{ rel: 'stylesheet', href: thebeCoreCss }, | ||
{ rel: 'stylesheet', href: '/myst-theme.css' }, | ||
{ | ||
rel: 'stylesheet', | ||
href: 'https://cdn.jsdelivr.net/npm/[email protected]/css/mpl_widget.css', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { type LoaderFunction } from '@remix-run/node'; | ||
import { type ThemeCssOptions, themeCSS, cssResponse } from '@myst-theme/site'; | ||
import { getConfig } from '~/utils/loaders.server'; | ||
|
||
export const loader: LoaderFunction = async (): Promise<Response> => { | ||
const site = await getConfig(); | ||
return cssResponse(themeCSS(site?.options as ThemeCssOptions)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ export const links: LinksFunction = () => { | |
}, | ||
{ rel: 'stylesheet', href: tailwind }, | ||
{ rel: 'stylesheet', href: thebeCoreCss }, | ||
{ rel: 'stylesheet', href: '/myst-theme.css' }, | ||
{ | ||
rel: 'stylesheet', | ||
href: 'https://cdn.jsdelivr.net/npm/[email protected]/css/mpl_widget.css', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { type LoaderFunction } from '@remix-run/node'; | ||
import { type ThemeCssOptions, themeCSS, cssResponse } from '@myst-theme/site'; | ||
import { getConfig } from '~/utils/loaders.server'; | ||
|
||
export const loader: LoaderFunction = async (): Promise<Response> => { | ||
const site = await getConfig(); | ||
return cssResponse(themeCSS(site?.options as ThemeCssOptions)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters