import clsx from 'clsx';
import { File, Folder, GitBranch, GitCommitHorizontal, List } from 'lucide-solid';
import { A, useNavigate, useParams } from '@solidjs/router';
import { createQuery, keepPreviousData, useQueryClient } from '@tanstack/solid-query';
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, type Component } from 'solid-js';
import { buildBlobDataUrl, decodeBlobText, getRepoBlob, getRepoBranches, getRepoDefaultBranch, getRepoLanguages, getRepoLog, getRepoTags, getRepoTree } from '../../lib/api/repos';
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, type Accessor, type Component } from 'solid-js';
import { buildBlobDataUrl, decodeBlobText, getRepoBlob, getRepoBranches, getRepoDefaultBranch, getRepoLanguages, getRepoLog, getRepoTags, getRepoTree, type CommitHeadline } from '../../lib/api/repos';
import { Avatar, ErrorState, PlaceholderAvatar, buttonStyles, cardStyles } from '../../components/common';
import { CloneDropdown, CodeView, FileRow, MarkdownBlock, OverviewFileRow, ReadmeCard, RepoBlobSkeleton, RepoLanguageBarSkeleton, RepoTreeSkeleton } from '../../components/repo';
import { RepoFrame, useRepoQuery } from './shared';
import { blobHref, commitHref, commitsHref, countLines, decodeRoutePath, formatBytes, formatLanguagePercent, formatRelativeTime, getErrorMessage, getParentPath, imageLike, isDirectory, joinPath, languageColor, markdownLike, safeDecode, sortedTreeEntries, svgLike, treeHref, updateRecentRepoLanguage, videoLike } from '../../lib/repo-utils';
881 unmodified lines
Expand all
const isMarkdown = createMemo(() => markdownLike(path(), blob.mimeType));
const isSvg = createMemo(() => svgLike(path(), blob.mimeType));
const isVideo = createMemo(() => videoLike(path(), blob.mimeType));
const isImage = createMemo(() => imageLike(path(), blob.mimeType));
const showingText = createMemo(
() => blob.content !== undefined && !blob.fileTooLarge && (!blob.isBinary || isSvg()),
);
const lineCount = createMemo(() => countLines(text()));
const showingText = createMemo(
() => blob.content !== undefined && !blob.fileTooLarge && (!blob.isBinary || isSvg()),
);
const lineCount = createMemo(() => countLines(text()));
const commitLink = (commit: Accessor<CommitHeadline>) => `/${repo.owner.handle}/${repo.slug}/commit/${commit().hash}`;
return (
<div class="untangled-blob-card peer">
<div class="untangled-blob-header pb-2 mb-3 text-base border-b border-gray-200 dark:border-gray-700">
<span class="font-medium text-gray-700 dark:text-gray-200">
{commit().author?.name || 'unknown author'}
</span>
<span class="select-none text-gray-400 dark:text-gray-500">·</span>
<span class="truncate text-gray-900 dark:text-gray-100">{commit().message.trim().split('\n')[0]}</span>
<A href={commitLink(commit)} class="truncate text-gray-900 dark:text-gray-100">{commit().message.trim().split('\n')[0]}</A>
<span class="select-none text-gray-400 dark:text-gray-500">·</span>
<span class="text-gray-400 dark:text-gray-500">{formatRelativeTime(commit().when)}</span>
<A href={commitLink(commit)} class="text-gray-400 dark:text-gray-500">{formatRelativeTime(commit().when)}</A>
</div>
<A
href={`/${repo.owner.handle}/${repo.slug}/commit/${commit().hash}`}
href={commitLink(commit)}
class="untangled-blob-commit-link"
>
{commit().hash.slice(0, 8)}
</A>