mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-19 20:13:01 +03:00
Cleanup styling
This commit is contained in:
@@ -17,36 +17,77 @@ marked.setOptions({ gfm: true });
|
|||||||
* @property {string} yaml Raw YAML for the configuration step.
|
* @property {string} yaml Raw YAML for the configuration step.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Render a markdown string to React nodes. Fenced code blocks become Docusaurus
|
||||||
|
// CodeBlock components (so they get syntax highlighting and a copy button);
|
||||||
|
// everything else is marked-parsed to HTML.
|
||||||
|
function renderBlocks(md, keyPrefix) {
|
||||||
|
if (!md.trim()) return [];
|
||||||
|
const tokens = marked.lexer(md);
|
||||||
|
const nodes = [];
|
||||||
|
let buffer = [];
|
||||||
|
let idx = 0;
|
||||||
|
|
||||||
|
const flush = () => {
|
||||||
|
if (buffer.length) {
|
||||||
|
buffer.links = tokens.links;
|
||||||
|
nodes.push(
|
||||||
|
<div
|
||||||
|
key={`${keyPrefix}-h${idx++}`}
|
||||||
|
dangerouslySetInnerHTML={{ __html: marked.parser(buffer) }}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
buffer = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tokens.forEach((token) => {
|
||||||
|
if (token.type === "code") {
|
||||||
|
flush();
|
||||||
|
const language = (token.lang || "text").split(/\s+/)[0];
|
||||||
|
nodes.push(
|
||||||
|
<CodeBlock key={`${keyPrefix}-c${idx++}`} language={language}>
|
||||||
|
{token.text}
|
||||||
|
</CodeBlock>,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
buffer.push(token);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
flush();
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
// marked does not understand Docusaurus admonitions (:::warning ... :::), so
|
// marked does not understand Docusaurus admonitions (:::warning ... :::), so
|
||||||
// render those blocks ourselves and marked-parse everything around them.
|
// render those blocks ourselves and render everything around them normally.
|
||||||
function renderMarkdown(md) {
|
function renderMarkdown(md) {
|
||||||
if (!md) return "";
|
if (!md) return null;
|
||||||
const admonition = /:::(\w+)[ \t]*([^\n]*)\n([\s\S]*?)\n:::/g;
|
const admonition = /:::(\w+)[ \t]*([^\n]*)\n([\s\S]*?)\n:::/g;
|
||||||
let html = "";
|
const nodes = [];
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
let match;
|
let match;
|
||||||
|
let k = 0;
|
||||||
while ((match = admonition.exec(md)) !== null) {
|
while ((match = admonition.exec(md)) !== null) {
|
||||||
html += marked.parse(md.slice(lastIndex, match.index));
|
nodes.push(...renderBlocks(md.slice(lastIndex, match.index), `seg${k}`));
|
||||||
const [, type, title, body] = match;
|
const [, type, title, body] = match;
|
||||||
const heading = (title || type).trim();
|
const heading = (title || type).trim();
|
||||||
html +=
|
nodes.push(
|
||||||
`<div class="${styles.admonition} ${styles[`admonition_${type}`] || ""}">` +
|
<div
|
||||||
`<div class="${styles.admonitionTitle}">${heading}</div>` +
|
key={`adm${k}`}
|
||||||
marked.parse(body) +
|
className={`${styles.admonition} ${styles[`admonition_${type}`] || ""}`}
|
||||||
`</div>`;
|
>
|
||||||
|
<div className={styles.admonitionTitle}>{heading}</div>
|
||||||
|
{renderBlocks(body, `adm${k}`)}
|
||||||
|
</div>,
|
||||||
|
);
|
||||||
lastIndex = admonition.lastIndex;
|
lastIndex = admonition.lastIndex;
|
||||||
|
k++;
|
||||||
}
|
}
|
||||||
html += marked.parse(md.slice(lastIndex));
|
nodes.push(...renderBlocks(md.slice(lastIndex), `seg${k}`));
|
||||||
return html;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Markdown({ children }) {
|
function Markdown({ children }) {
|
||||||
return (
|
return <div className={styles.markdown}>{renderMarkdown(children)}</div>;
|
||||||
<div
|
|
||||||
className={styles.markdown}
|
|
||||||
dangerouslySetInnerHTML={{ __html: renderMarkdown(children) }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function RecommendedBadge() {
|
function RecommendedBadge() {
|
||||||
|
|||||||
@@ -9,8 +9,9 @@
|
|||||||
/* --- Dropdown button --- */
|
/* --- Dropdown button --- */
|
||||||
|
|
||||||
.dropdown {
|
.dropdown {
|
||||||
display: block;
|
display: inline-block;
|
||||||
width: 100%;
|
width: 360px;
|
||||||
|
max-width: 100%;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border: 1px solid var(--ifm-color-emphasis-400);
|
border: 1px solid var(--ifm-color-emphasis-400);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@@ -71,13 +72,16 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.75rem 1rem;
|
gap: 1rem;
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Model menu --- */
|
/* --- Model menu --- */
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
|
width: 360px;
|
||||||
|
max-width: 100%;
|
||||||
border: 1px solid var(--ifm-color-emphasis-400);
|
border: 1px solid var(--ifm-color-emphasis-400);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -133,6 +137,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.recommendedBadge {
|
.recommendedBadge {
|
||||||
@@ -189,10 +194,8 @@
|
|||||||
|
|
||||||
.stepTitle {
|
.stepTitle {
|
||||||
margin: 0 0 0.75rem 0;
|
margin: 0 0 0.75rem 0;
|
||||||
font-size: 0.8rem;
|
font-size: 1rem;
|
||||||
font-weight: 700;
|
font-weight: 600;
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
color: var(--ifm-font-color-base);
|
color: var(--ifm-font-color-base);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,10 +223,6 @@
|
|||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown pre {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Docusaurus-style admonitions rendered from markdown. */
|
/* Docusaurus-style admonitions rendered from markdown. */
|
||||||
|
|
||||||
.admonition {
|
.admonition {
|
||||||
|
|||||||
Reference in New Issue
Block a user