docs: improve admonition styles (#1880)
This commit is contained in:
@@ -75,4 +75,5 @@ rendered.
|
||||
|
||||
The rendered page will only include the `<meta>`-tag with `"Other title"`.
|
||||
|
||||
> ℹ️ The `<title>`-tag is automatically deduplicated, even without a `key` prop.
|
||||
> [info]: The `<title>`-tag is automatically deduplicated, even without a `key`
|
||||
> prop.
|
||||
|
||||
@@ -30,9 +30,9 @@ This will create a `_fresh` folder in the project directory. That folder
|
||||
contains the optimized assets and a `snapshot.json` file which includes some
|
||||
metadata for Fresh.
|
||||
|
||||
> ℹ️ The `_fresh` folder should not be committed to the repository. Add an entry
|
||||
> in the `.gitignore` file to ensure that it is not committed. Create that file
|
||||
> at the root of your git repository if not present.
|
||||
> [info]: The `_fresh` folder should not be committed to the repository. Add an
|
||||
> entry in the `.gitignore` file to ensure that it is not committed. Create that
|
||||
> file at the root of your git repository if not present.
|
||||
>
|
||||
> ```gitignore .gitignore
|
||||
> # Ignore fresh build directory
|
||||
|
||||
@@ -97,8 +97,9 @@ a folder and use a different `_layout` file for each group.
|
||||
└── contact.tsx
|
||||
```
|
||||
|
||||
> ℹ️ Be careful about routes in different groups which match to the same URL.
|
||||
> Such scenarios will lead to ambiguity as to which route file should be picked.
|
||||
> [warn]: Be careful about routes in different groups which match to the same
|
||||
> URL. Such scenarios will lead to ambiguity as to which route file should be
|
||||
> picked.
|
||||
>
|
||||
> ```txt Project structure
|
||||
> └── routes
|
||||
|
||||
@@ -29,7 +29,7 @@ this, one needs to create a new `routes/about.tsx` file. In this file, we can
|
||||
declare a component that should be rendered every time a user visits the page.
|
||||
This is done with JSX.
|
||||
|
||||
> ℹ️ To learn more about JSX, you can read [this article][jsx] in the React
|
||||
> [info]: To learn more about JSX, you can read [this article][jsx] in the React
|
||||
> documentation. Beware that Fresh does not use React, but rather
|
||||
> [Preact][preact], a lighter weight virtual dom library that works similar to
|
||||
> React.
|
||||
|
||||
@@ -37,6 +37,60 @@ const CSS = css`${gfm.CSS}
|
||||
margin-left: 0
|
||||
}
|
||||
|
||||
.markdown-body .admonition {
|
||||
padding: 1rem;
|
||||
}
|
||||
.markdown-body .admonition-header {
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 1rem;
|
||||
padding-bottom: .5rem;
|
||||
}
|
||||
.markdown-body .admonition .icon {
|
||||
display: inline-flex;
|
||||
margin-right: .25rem;
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
}
|
||||
.markdown-body blockquote.warn {
|
||||
border-color: #ff9100;
|
||||
background: #F0900525;
|
||||
}
|
||||
|
||||
.markdown-body .admonition .fenced-code {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
border: 1px solid #d9d2d2;
|
||||
border-radius: .5rem .5rem .25rem .25rem;
|
||||
}
|
||||
|
||||
.markdown-body .admonition .highlight {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.markdown-body .admonition.tip .admonition-header {
|
||||
color: rgb(0, 148, 0);
|
||||
}
|
||||
.markdown-body .admonition.tip {
|
||||
background-color: rgb(230, 246, 230);
|
||||
border-color: rgb(0, 148, 0);
|
||||
}
|
||||
.markdown-body .admonition.info .admonition-header {
|
||||
color: rgb(25 146 184);
|
||||
}
|
||||
.markdown-body .admonition.info {
|
||||
background-color: rgb(238, 249, 253);
|
||||
border-color: rgb(25 146 184);
|
||||
}
|
||||
.markdown-body .admonition.warn .admonition-header {
|
||||
color: #dd6f04;
|
||||
}
|
||||
.markdown-body .admonition.warn {
|
||||
background-color: #F0900525;
|
||||
border-color: #ff9100;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.markdown-body .fenced-code,
|
||||
.markdown-body table {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="tip" viewBox="0 0 24 24">
|
||||
<g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M3 12h1m8 -9v1m8 8h1m-15.4 -6.4l.7 .7m12.1 -.7l-.7 .7" />
|
||||
<path d="M9 16a5 5 0 1 1 6 0a3.5 3.5 0 0 0 -1 3a2 2 0 0 1 -4 0a3.5 3.5 0 0 0 -1 -3" />
|
||||
<path d="M9.7 17l4.6 0" />
|
||||
</g>
|
||||
</symbol>
|
||||
|
||||
<symbol id="info" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" />
|
||||
<path d="M12 9h.01" />
|
||||
<path d="M11 12h1v4h1" />
|
||||
</symbol>
|
||||
|
||||
<symbol id="warn" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M12 9v4" />
|
||||
<path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" />
|
||||
<path d="M12 16h.01" />
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -16,6 +16,8 @@ import { mangle } from "$marked-mangle";
|
||||
|
||||
Marked.marked.use(mangle());
|
||||
|
||||
const ADMISSION_REG = /^<p>\[(info|warn|tip)\]:\s/;
|
||||
|
||||
class DefaultRenderer extends Marked.Renderer {
|
||||
text(text: string): string {
|
||||
// Smartypants typography enhancement
|
||||
@@ -97,6 +99,25 @@ class DefaultRenderer extends Marked.Renderer {
|
||||
out += `</div>`;
|
||||
return out;
|
||||
}
|
||||
|
||||
blockquote(quote: string): string {
|
||||
const match = quote.match(ADMISSION_REG);
|
||||
console.log(match, quote);
|
||||
if (match) {
|
||||
const label: Record<string, string> = {
|
||||
tip: "Tip",
|
||||
warn: "Warning",
|
||||
info: "Info",
|
||||
};
|
||||
const type = match[1];
|
||||
quote = quote.slice(match[0].length);
|
||||
const icon = `<svg class="icon"><use href="/icons.svg#${type}" /></svg>`;
|
||||
return `<blockquote class="admonition ${type}">\n<span class="admonition-header">${icon}${
|
||||
label[type]
|
||||
}</span>${quote}</blockquote>\n`;
|
||||
}
|
||||
return `<blockquote>\n${quote}</blockquote>\n`;
|
||||
}
|
||||
}
|
||||
|
||||
export interface MarkdownOptions {
|
||||
|
||||
Reference in New Issue
Block a user