getBuildPath method

String getBuildPath(
  1. Config config
)

Get final build path for this Page.

Index file is kept as is, only file extension is changed to HTML. For regular page is created a subdirectory with index.html file.

Example: content/post.md -> public/post/index.html content/index.md -> public/index.html

Implementation

String getBuildPath(Config config) {
  final basename = Path.basenameWithoutExtension(path);
  final dirName = Path.dirname(path);

  if (isIndex) {
    // Index file may be named `index` or `_index`.
    // Underscore needs to be removed.
    final name = basename.startsWith('_') ? basename.substring(1) : basename;
    return Path.normalize(
      Path.join(
        config.build.publicDir,
        dirName,
        '$name.html',
      ),
    );
  } else {
    return Path.normalize(
      Path.join(
        config.build.publicDir,
        dirName,
        basename,
        'index.html',
      ),
    );
  }
}