边缘星云

返回

内容展示

关于内容页面渲染

Shiki 代码

你可以在配置文件 astro.config.ts 的 defineConfig.markdown.shikiConfig 中更改转换器。

基本用法

对于 .astro 文件:

---
import { Code } from 'astro:components'
---

<Code lang='shell' code={`git log --oneline`} />
astro

对于 .mdx 和 .md 文件:

```shell
git log --oneline
```
markdown

添加标题

start.sh
#!/bin/bash

bun check &
bun dev
shell
```shell title="start.sh"
#!/bin/bash

bun check &
bun dev
```
markdown

显示差异

支持新增和删除行。

deploy.sh
#!/bin/bash

bun check
bun lint
bun format
# No need for vercel or other ci/cd
bun run build
git push
shell
```shell title="deploy.sh"
#!/bin/bash

bun check
bun lint
bun format # [!code ++]
# No need for vercel or other ci/cd
bun run build # [!code --]
git push
```
markdown

显示高亮

内容过时提醒

如果文章足够旧,添加一条提醒消息。

src/layouts/BlogPost.astro
---
// ...
---
  <Hero {data} {remarkPluginFrontmatter} slot='header'>
    <Fragment slot='description'>
      {!isDraft && enableComment && <PageInfo comment class='mt-1' />}
      { 
        Math.floor((Date.now() - new Date(articleDate).getTime()) / 86400000) > 365 && ( 
          <p class='mt-1 text-sm italic text-primary' style='--primary:41 90% 50%'> <!-- [!code ++] -->
            This article was last updated over a year ago. Some information may be outdated. <!-- [!code ++] -->
          </p> 
        ) 
      } 
    </Fragment>
  </Hero>
astro

渲染效果如下:

这篇文章上次更新已超过一年,部分信息可能已过时。