Advanced Components

Advanced components with advanced docs

Web Content Render

Quote

The Quote component is a simple component that displays a random quote.

学了的,就要做出来。

import { Quote } from 'astro-pure/advanced'

<Quote />
jsx

Config:

src/site.config.ts
export const integ: IntegrationUserConfig = {
  // Add a random quote to the footer (default on homepage footer)
  quote: {
    // https://github.com/lukePeavey/quotable
    server: 'https://api.quotable.io/quotes/random?maxLength=60', 
    target: `(data) => data[0].content || 'Error'`
  }
}
ts

Quotable(原站外链接,已停用) is a open-source API that provides random English quotes.

For Chinese quotes, you can use Hitokoto(原站外链接,已停用).

src/site.config.ts
export const integ: IntegrationUserConfig = {
  quote: {
    // https://developer.hitokoto.cn/sentence/#%E8%AF%B7%E6%B1%82%E5%9C%B0%E5%9D%80
    server: 'https://v1.hitokoto.cn/?c=i', 
    target: `(data) => data.hitokoto || 'Error'`
  }
}
ts

GitHub Card

The GithubCard component is a simple component that displays a GitHub user card.

cworld1/ astro-theme-pure

外部仓库数据(星标、分支、许可证)不再实时拉取,以避免运行时请求第三方接口。

import { GithubCard } from 'astro-pure/advanced'

<GithubCard repo='cworld1/astro-theme-pure' />
jsx

Preview any link inserted in the content.

站外引用

mozilla.org

https://www.mozilla.org/en-US/

站外链接与预览已停用。

站外引用

cloudflare.com

https://www.cloudflare.com/

站外链接与预览已停用。

import { LinkPreview } from 'astro-pure/advanced'

<LinkPreview href='https://www.cloudflare.com/' />
// `zoomable` option will control mediumzoom tag
// <LinkPreview href='https://www.cloudflare.com/' zoomable={false} />
<LinkPreview href='https://www.cloudflare.com/' hideMedia />
jsx

Data Transformer

QRCode

二维码组件未启用:本站不加载站外脚本,也不生成可分享到站外的二维码。 目标内容:https://github.com/cworld1/astro-theme-pure
import { QRCode } from 'astro-pure/advanced'

// <QRCode /> // default to render current page link
<QRCode
  content='https://github.com/cworld1/astro-theme-pure'
  class='inline-flex max-w-44 p-3 bg-muted rounded-lg border' />
jsx

Toast

Click Me
import { Button } from 'astro-pure/basic'

<Button
  title='Click Me'
  onClick={`document.dispatchEvent(
    new CustomEvent('toast', {
      detail: {
        message: 'Hello from toast!',
        time: 5000
      }
    })
  )`} /> 
jsx

Medium Zoom

Try click the following image.

[外部图片:https://github.com/user-attachments/assets/6c42b061-df7e-4696-a29b-bff07fe17d88]

See Other Integrations#medium-zoom.

内容归属:CuiFrost

内容索引