Skip to content

dirname

reference
1 min readUpdated

Kind: Function

Source: src/helper/ssg/utils.ts

Part of: Helper

Get dirname

dirname gets the directory portion of a file or path string. It supports static-site-generation helpers that need to locate a file's parent directory before resolving related paths or writing output.

Signature

ts
function dirname(path: string): string

Parameters

NameType
pathstring

Returns: string

Diagram

mermaid
graph LR
  A[Path string] --> B[dirname]
  B --> C[Directory path]

Usage

ts
import { dirname } from '../src/helper/ssg/utils'

const filePath = 'content/guides/setup.mdx'
const directory = dirname(filePath)

console.log(directory)

AI Coding Instructions

  • Pass a path string representing a file or nested resource.
  • Use the returned directory path when resolving files relative to the current resource.
  • Keep path-format handling consistent with other SSG utilities.
  • Check callers that may pass root-level paths or paths without directory segments.

Relationships

  • IMPORTS → METHOD_NAME_ALL
  • IMPORTS → findTargetHandler
  • IMPORTS → isMiddleware

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • DEFAULT_OUTPUT_DIRsrc/helper/ssg/ssg.ts:27

Was this page helpful?

Download as PDF
dirname — Hono (narrator proof)