Astro Theme Pure

Back

Content Presentation

About Content Page Rendering

Shiki Code#

You can change transformer at defineConfig.markdown.shikiConfig in config file astro.config.ts.

Basic Usage#

For .astro file:

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

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

For .mdx and .md file:

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

Add Title#

start.sh
#!/bin/bash

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

bun check &
bun dev
```
markdown

Show Diff#

Supports add and del lines.

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

Show Highlight#

Content Obsolete Warning#

Add a warning message if the article is old enough.

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

It will render like this:

This article was last updated over a year ago. Some information may be outdated.