docs: update more pages for Fresh 2 (#3141)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
---
|
||||
description: |
|
||||
Style active links with ease in Fresh
|
||||
---
|
||||
|
||||
Fresh automatically enhances the accessibility of `<a>` elements by adding the
|
||||
aria-current attribute when rendering links that match the current URL. This
|
||||
attribute is recognized by assistive technologies and clearly indicates the
|
||||
current page within a set of pages.
|
||||
|
||||
- `aria-current="page"` - Added to links with an exact path match, enhancing
|
||||
accessibility by indicating the current page to assistive technologies.
|
||||
|
||||
As we aim to improve accessibility, we encourage the use of aria-current for
|
||||
styling current links where applicable.
|
||||
|
||||
## Styling with CSS
|
||||
|
||||
The aria-current attribute is easily styled with CSS using attribute selectors,
|
||||
providing a native way to visually differentiate the active link.
|
||||
|
||||
```css
|
||||
/* Give links pointing to the current page a green color */
|
||||
a[aria-current="page"] {
|
||||
color: green;
|
||||
}
|
||||
|
||||
/* Color all ancestor links of the current page */
|
||||
a[aria-current="true"] {
|
||||
color: peachpuff;
|
||||
}
|
||||
```
|
||||
|
||||
## Tailwindcss
|
||||
|
||||
In Tailwindcss or similar CSS frameworks, you can apply styles to elements with
|
||||
the `aria-current` attribute using bracket notation in your class definitions.
|
||||
For Tailwindcss, use the syntax:
|
||||
|
||||
```tsx
|
||||
function Menu() {
|
||||
return (
|
||||
<a href="/foo" class="aria-[current]:text-green-600">
|
||||
Link to some page
|
||||
</a>
|
||||
);
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
description: |
|
||||
How to render markdown on your Fresh site.
|
||||
---
|
||||
|
||||
[Markdown](https://www.markdownguide.org/basic-syntax/) is a common text-based
|
||||
file format that is often used for writing documentation, blogs and more. In
|
||||
this example we are going convert markdown content to HTML and send it to the
|
||||
browser.
|
||||
|
||||
First, let's install the [`@deno/gfm`](https://jsr.io/@deno/gfm) package that
|
||||
can transform markdown to html.
|
||||
|
||||
1. Run `deno install jsr:@deno/gfm`
|
||||
2. Create a markdown file like `content.md`:
|
||||
|
||||
```md
|
||||
## some heading
|
||||
|
||||
and some interesting text here
|
||||
|
||||
> oh look a blockquote
|
||||
```
|
||||
|
||||
4. Add a route that renders that file
|
||||
|
||||
```tsx
|
||||
import { CSS, render as renderMarkdown } from "@deno/gfm";
|
||||
|
||||
const CONTENT = `## some heading
|
||||
|
||||
and some interesting text here
|
||||
|
||||
> oh look a blockquote
|
||||
`;
|
||||
|
||||
const app = new App();
|
||||
|
||||
app.get("/", async (ctx) => {
|
||||
const content = await Deno.readTextFile("path/to/content.md");
|
||||
const html = renderMarkdown(content);
|
||||
|
||||
return await ctx.render(
|
||||
<div>
|
||||
<h1>Here comes a markdown post:</h1>
|
||||
<style dangerouslySetInnerHTML={{ __html: CSS }} />
|
||||
<div dangerouslySetInnerHTML={{ __html: html }} />
|
||||
</div>,
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
## Other libraries
|
||||
|
||||
There are several other popular libraries besides `@deno/gfm` that can be used
|
||||
to render markdown. The most common ones are:
|
||||
|
||||
- [marked](https://marked.js.org/)
|
||||
- [remark](https://remark.js.org/)
|
||||
Reference in New Issue
Block a user