-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
848 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
imports.autoImport=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { loadShiki } from './composables/shiki' | ||
import { data, refreshSources } from './composables/state' | ||
await loadShiki() | ||
const loading = ref(false) | ||
async function refresh() { | ||
loading.value = true | ||
await refreshSources() | ||
setTimeout(() => { | ||
loading.value = false | ||
}, 300) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="relative p8 n-bg-base flex flex-col h-screen"> | ||
<div> | ||
<div class="flex justify-between" mb6> | ||
<div> | ||
<h1 text-xl mb2 flex items-center gap-2> | ||
<NIcon icon="carbon:load-balancer-application text-blue-300" /> | ||
Nuxt Simple Sitemap <span v-if="data?.buildTimeMeta" class="text-sm opacity-60">{{ data.buildTimeMeta.version }}</span> | ||
</h1> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="flex items-center space-x-5"> | ||
<div> | ||
<h2 text-lg mb2 flex items-center gap-2> | ||
<NIcon icon="carbon:connect-source opacity-50" /> | ||
Sources <span class="text-sm opacity-60">{{ data?.sources.length }}</span> | ||
</h2> | ||
<p text-sm op60 mb3> | ||
See the sources used to generate your sitemap. | ||
</p> | ||
</div> | ||
<button | ||
class="mr-5 hover:shadow-lg text-xs transition items-center gap-2 inline-flex border-green-500/50 border-1 rounded-lg shadow-sm px-3 py-1" | ||
@click="refresh" | ||
> | ||
<div v-if="!loading"> | ||
Refresh | ||
</div> | ||
<NIcon v-else icon="carbon:progress-bar-round" class="animated animate-spin op50 text-xs" /> | ||
</button> | ||
</div> | ||
<div class="space-y-10"> | ||
<div v-for="source in data?.sources"> | ||
<div v-if="source.count > 0" class="mb-3"> | ||
<h3 class="text-gray-800 text-base mb-1"> | ||
{{ source.context }} <span class="bg-gray-100 rounded text-gray-500 px-1 text-xs">{{ source.count }}</span> | ||
</h3> | ||
<div v-if="source.path" class="text-sm flex items-center opacity-70 space-x-3"> | ||
<div>{{ source.path }}</div> | ||
<div v-if="source.timeTakenMs" class="text-gray-700"> | ||
{{ source.timeTakenMs }}ms | ||
</div> | ||
</div> | ||
</div> | ||
<OCodeBlock class="max-h-[350px] max-w-2/3 overflow-y-auto" :code="JSON.stringify(source.urls, null, 2)" lang="json" /> | ||
</div> | ||
</div> | ||
<div class="flex-auto" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script setup lang="ts"> | ||
import type { Lang } from 'shiki-es' | ||
import { computed } from 'vue' | ||
import { renderCodeHighlight } from '../composables/shiki' | ||
const props = withDefaults( | ||
defineProps<{ | ||
code: string | ||
lang?: Lang | ||
lines?: boolean | ||
transformRendered?: (code: string) => string | ||
}>(), | ||
{ | ||
lines: true, | ||
}, | ||
) | ||
const rendered = computed(() => { | ||
const code = renderCodeHighlight(props.code, props.lang) | ||
return props.transformRendered ? props.transformRendered(code.value || '') : code.value | ||
}) | ||
</script> | ||
|
||
<template> | ||
<pre | ||
class="n-code-block" | ||
:class="lines ? 'n-code-block-lines' : ''" | ||
v-html="rendered" | ||
/> | ||
</template> | ||
|
||
<style> | ||
.n-code-block-lines .shiki code { | ||
counter-reset: step; | ||
counter-increment: step calc(var(--start, 1) - 1); | ||
} | ||
.n-code-block-lines .shiki code .line::before { | ||
content: counter(step); | ||
counter-increment: step; | ||
width: 2rem; | ||
padding-right: 0.5rem; | ||
margin-right: 0.5rem; | ||
display: inline-block; | ||
text-align: right; | ||
--at-apply: text-truegray:50; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { createTemplatePromise } from '@vueuse/core' | ||
|
||
export const FixDialog = createTemplatePromise<boolean, [any]>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { onDevtoolsClientConnected } from '@nuxt/devtools-kit/iframe-client' | ||
import type { $Fetch } from 'nitropack' | ||
import { ref } from 'vue' | ||
import type { NuxtDevtoolsClient } from '@nuxt/devtools-kit/dist/types' | ||
import { refreshSources } from './state' | ||
|
||
export const appFetch = ref<$Fetch>() | ||
|
||
export const devtools = ref<NuxtDevtoolsClient>() | ||
|
||
onDevtoolsClientConnected(async (client) => { | ||
appFetch.value = client.host.app.$fetch | ||
devtools.value = client.devtools | ||
refreshSources() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { Highlighter, Lang } from 'shiki-es' | ||
import { getHighlighter } from 'shiki-es' | ||
import { computed, ref, unref } from 'vue' | ||
import type { MaybeRef } from '@vueuse/core' | ||
import { devtools } from './rpc' | ||
|
||
export const shiki = ref<Highlighter>() | ||
|
||
export function loadShiki() { | ||
// Only loading when needed | ||
return getHighlighter({ | ||
themes: [ | ||
'vitesse-dark', | ||
'vitesse-light', | ||
], | ||
langs: [ | ||
'css', | ||
'javascript', | ||
'typescript', | ||
'html', | ||
'vue', | ||
'vue-html', | ||
'bash', | ||
'diff', | ||
], | ||
}).then((i) => { | ||
shiki.value = i | ||
}) | ||
} | ||
|
||
export function renderCodeHighlight(code: MaybeRef<string>, lang?: Lang) { | ||
return computed(() => { | ||
const colorMode = devtools.value?.colorMode || 'light' | ||
return shiki.value!.codeToHtml(unref(code), { | ||
lang, | ||
theme: colorMode === 'dark' ? 'vitesse-dark' : 'vitesse-light', | ||
}) || '' | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ref } from 'vue' | ||
import { appFetch } from './rpc' | ||
|
||
export const data = ref<any>(null) | ||
|
||
export async function refreshSources() { | ||
if (appFetch.value) | ||
data.value = await appFetch.value('/api/__sitemap__/debug') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { resolve } from 'pathe' | ||
import DevtoolsUIKit from '@nuxt/devtools-ui-kit' | ||
|
||
export default defineNuxtConfig({ | ||
ssr: false, | ||
modules: [ | ||
DevtoolsUIKit, | ||
], | ||
devtools: { | ||
enabled: false, | ||
}, | ||
nitro: { | ||
output: { | ||
publicDir: resolve(__dirname, '../dist/client'), | ||
}, | ||
}, | ||
app: { | ||
baseURL: '/__nuxt-simple-sitemap', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "nuxt-simple-sitemap-client", | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.