@@ -108,11 +108,6 @@ const isViewingFile = computed(() => currentNode.value?.type === 'file')
108108const MAX_FILE_SIZE = 500 * 1024
109109
110110const isBinaryFile = computed (() => !! filePath .value && isBinaryFilePath (filePath .value ))
111- const showBinaryContent = shallowRef (false )
112-
113- watch (filePath , () => {
114- showBinaryContent .value = false
115- })
116111
117112const isFileTooLarge = computed (() => {
118113 const size = currentNode .value ?.size
@@ -122,11 +117,13 @@ const isFileTooLarge = computed(() => {
122117// Fetch file content when a file is selected (and not too large)
123118const fileContentUrl = computed (() => {
124119 // Don't fetch if no file path, file tree not loaded, file is too large, or it's a directory
125- if (! filePath .value || ! fileTree .value || isFileTooLarge .value || ! isViewingFile .value ) {
126- return null
127- }
128- // Don't fetch binary files until user explicitly requests rendering
129- if (isBinaryFile .value && ! showBinaryContent .value ) {
120+ if (
121+ ! filePath .value ||
122+ ! fileTree .value ||
123+ isFileTooLarge .value ||
124+ ! isViewingFile .value ||
125+ isBinaryFile .value
126+ ) {
130127 return null
131128 }
132129 return ` /api/registry/file/${packageName .value }/v/${version .value }/${filePath .value } `
@@ -533,24 +530,16 @@ defineOgImageComponent('Default', {
533530 </template >
534531
535532 <!-- Binary file warning -->
536- <div
537- v-else-if =" isViewingFile && isBinaryFile && !showBinaryContent"
538- class =" py-20 text-center"
539- >
533+ <div v-else-if =" isViewingFile && isBinaryFile" class =" py-20 text-center" >
540534 <div class =" i-lucide:binary w-12 h-12 mx-auto text-fg-subtle mb-4" />
541535 <p class =" text-fg-muted mb-2" >{{ $t('code.binary_file') }}</p >
542536 <p class =" text-fg-subtle text-sm mb-4" >{{ $t('code.binary_rendering_warning') }}</p >
543- <div class =" flex items-center justify-center gap-3" >
544- <ButtonBase @click =" showBinaryContent = true" >{{
545- $t('code.render_anyway')
546- }}</ButtonBase >
547- <LinkBase
548- variant =" button-secondary"
549- :to =" `https://cdn.jsdelivr.net/npm/${packageName}@${version}/${filePath}`"
550- >
551- {{ $t('code.view_raw') }}
552- </LinkBase >
553- </div >
537+ <LinkBase
538+ variant =" button-secondary"
539+ :to =" `https://cdn.jsdelivr.net/npm/${packageName}@${version}/${filePath}`"
540+ >
541+ {{ $t('code.view_raw') }}
542+ </LinkBase >
554543 </div >
555544
556545 <!-- File too large warning -->
0 commit comments