小区车位

技术相关

Nuxt Content

之前使用 Nuxt3 开发的个人网站,上周丰富了一下博客内容。使用了 Nuxt Content,感觉还是很好用的。

Formmatter 还是一如既往的规则,跟 VitePress 或者 Astro 一样,都是使用 --- 来分割。

---
title: MDC
---

Test

然后还有一些其他有趣的 API ,比如检索,或者列表等等。 Heti

在渲染博客的时候,发现样式有点简陋,然后之前在 Fork Tw93 的 Weekly 的项目的时候,发现其中文的排版很好看,于是就去找了一下,发现是使用了 Heti 。然后就 下载 了一下,简单修改,然后就用上了。

useScriptTag(
  'https://gw.alipayobjects.com/os/k/h3/heti-addon.min.js',
  (el: HTMLScriptElement) => {
    const heti = new (window as any).Heti('.heti')
    heti.autoSpacing()
  },
)

在需要渲染的地方,使用 heti 类名,然后就可以了。

还有一个 min.css ,自定义一些 CSS 样式,很是方便。

Lozad.js

同上,也看到了图片懒加载的一个库,Lozad.js。

// 图片懒加载
useScriptTag(
  'https://gw.alipayobjects.com/os/k/3j/lozad.min.js',
  (el: HTMLScriptElement) => {
    const observer = (window as any).lozad('.lozad', {
      loaded(el: { alt: any, getAttribute: (arg0: string) => any }) {
        el.alt = el.getAttribute('data-alt')
      },
    })
    observer.observe()
  },
)

在需要懒加载图片的地方,使用 lozad 类名,然后就可以了。 Giscus

在 GitHub 仓库的 Discussion ,具体的配置直接看网站教程。

首先要启用 GitHub Public Repo 的 Discussions 功能,然后再在你的项目代码中引入 JS 就好了。

如果要局部刷新,参考这里:Giscus Refresh

这里是一个 Nuxt3 的简单配置代码:

// 注册调用
const { root: giscusRoot } = registerGiscus()

// 刷新
updateGiscusConfig({
  setConfig: {
    theme: 'https://giscus.app/themes/custom_example.css',
    reactionsEnabled: false,
    term: '01',
  },
})
interface ISetConfigMessage {
  setConfig: {
    theme?: any
    repo?: string
    repoId?: string
    category?: string
    categoryId?: string
    term?: string
    description?: string
    backLink?: string
    number?: number
    strict?: boolean
    reactionsEnabled?: boolean
    emitMetadata?: boolean
    inputPosition?: any
    lang?: any
  }
}

export function registerGiscus() {
  const root = ref<HTMLElement | null>()
  onMounted(() => {
    const giscusFrame = document.getElementById('giscus-frame')
    if (giscusFrame) {
      return null
    }
    else {
      const script = document.createElement('script')
      script.src = 'https://giscus.app/client.js'
      script.setAttribute('data-repo', 'pinky-pig/Arvin')
      script.setAttribute('data-repo-id', 'R_kgDOJI00wg')
      script.setAttribute('data-category', 'General')
      script.setAttribute('data-category-id', 'DIC_kwDOJI00ws4CWzuK')
      script.setAttribute('data-mapping', 'title')
      script.setAttribute('data-strict', '0')
      script.setAttribute('data-reactions-enabled', '1')
      script.setAttribute('data-emit-metadata', '0')
      script.setAttribute('data-input-position', 'bottom')
      script.setAttribute('data-theme', 'https://gw.alipayobjects.com/os/k/font7/comment.css')
      script.setAttribute('data-lang', 'zh-CN')
      script.setAttribute('data-loading', 'lazy')
      script.setAttribute('crossorigin', 'anonymous')
      script.setAttribute('async', '')
      root.value!.appendChild(script)
    }
  })
  return { root }
}

export function updateGiscusConfig(message: ISetConfigMessage) {
  const iframe = document.querySelector<HTMLIFrameElement>('iframe.giscus-frame')
  if (!iframe)
    return
  iframe.contentWindow!.postMessage({ giscus: message }, 'https://giscus.app')
}

20230529170849

20230529170925

生活相关

周末去交接房子了,然后收拾了一下,车子已经停在车位上了~~

车屁股

小区虽然外立面有点破,甚至周边几个老校区都已经出新,而这个小区没有,但是还是有点特色的,比如小区里面很安静,有很多枇杷树,有很多石榴树,还有很多老人在散步,还有很多小孩在玩耍,还有很多小区猫在晒太阳。

小区枇杷树

倒是昨天清理垃圾,在六楼,没有电梯,爬上爬下,累死了。

但是当看到干净的房子,还是很开心的。