Home / File/ blog.data.ts — vite Source File

blog.data.ts — vite Source File

Architecture documentation for blog.data.ts, a typescript file in the vite codebase. 1 imports, 0 dependents.

File typescript ViteCore ConfigEngine 1 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  38726e82_04b5_5692_3fb8_d7ba4a75f1ed["blog.data.ts"]
  ad381f08_4360_bc0b_d19c_44e6ee921d24["vitepress"]
  38726e82_04b5_5692_3fb8_d7ba4a75f1ed --> ad381f08_4360_bc0b_d19c_44e6ee921d24
  style 38726e82_04b5_5692_3fb8_d7ba4a75f1ed fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { createContentLoader } from 'vitepress'

interface Post {
  title: string
  url: string
  date: {
    time: number
    string: string
  }
}

declare const data: Post[]
export { data }

export default createContentLoader('blog/*.md', {
  // excerpt: true,
  transform(raw): Post[] {
    return raw
      .map(({ url, frontmatter }) => ({
        title: frontmatter.head.find(
          (e: any) => e[1].property === 'og:title',
        )[1].content,
        url,
        date: formatDate(frontmatter.date),
      }))
      .sort((a, b) => b.date.time - a.date.time)
  },
})

function formatDate(raw: string): Post['date'] {
  const date = new Date(raw)
  date.setUTCHours(12)
  return {
    time: +date,
    string: date.toLocaleDateString('en-US', {
      year: 'numeric',
      month: 'long',
      day: 'numeric',
    }),
  }
}

Domain

Subdomains

Classes

Types

Dependencies

  • vitepress

Frequently Asked Questions

What does blog.data.ts do?
blog.data.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in blog.data.ts?
blog.data.ts defines 2 function(s): default.transform, formatDate.
What does blog.data.ts depend on?
blog.data.ts imports 1 module(s): vitepress.
Where is blog.data.ts in the architecture?
blog.data.ts is located at docs/_data/blog.data.ts (domain: ViteCore, subdomain: ConfigEngine, directory: docs/_data).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free