TokyoStarz
TokyoStarz
NNuxt
Created by TokyoStarz on 9/4/2024 in #❓・help
is there a faster building dev version of nuxt generate
7 replies
NNuxt
Created by TokyoStarz on 9/4/2024 in #❓・help
is there a faster building dev version of nuxt generate
The nuxt team just shipped a build cache in experiments, that might actually solve my niche problem
7 replies
NNuxt
Created by TokyoStarz on 9/4/2024 in #❓・help
is there a faster building dev version of nuxt generate
I could probably set it up to forward non-api routes to the nuxt web server, that might work
7 replies
NNuxt
Created by TokyoStarz on 4/23/2024 in #❓・help
Need help ignoring shiki highlight hints in a copy button
this is my current hack:
import { useClipboard } from '@vueuse/core';
const { copy, copied } = useClipboard();
const props = withDefaults(
defineProps<{
code?: string;
language?: string | null;
filename?: string | null;
highlights?: Array<number>;
}>(),
{ code: '', language: null, filename: null, highlights: [] }
);

const codeElm = ref();

const copyCode = () => {
if (!codeElm.value) {
return;
}

let str = "";
let lines = codeElm.value.getElementsByClassName("line");
for (let i = 0; i < lines.length; i++) {
let line = lines[i]
str += line.textContent
if (!str.endsWith("\n") && i != lines.length - 1) {
str += "\n"
}
}

copy(str);
};
import { useClipboard } from '@vueuse/core';
const { copy, copied } = useClipboard();
const props = withDefaults(
defineProps<{
code?: string;
language?: string | null;
filename?: string | null;
highlights?: Array<number>;
}>(),
{ code: '', language: null, filename: null, highlights: [] }
);

const codeElm = ref();

const copyCode = () => {
if (!codeElm.value) {
return;
}

let str = "";
let lines = codeElm.value.getElementsByClassName("line");
for (let i = 0; i < lines.length; i++) {
let line = lines[i]
str += line.textContent
if (!str.endsWith("\n") && i != lines.length - 1) {
str += "\n"
}
}

copy(str);
};
rather than just doing copy(props.code) or copy(code) in the template
2 replies
NNuxt
Created by TokyoStarz on 4/15/2023 in #❓・help
How to catch 401 from server routes and redirect to login page
it works when I reload the page (getting a straight 401 from the server because SSR) but if my session gets invalidated then I try to navigate to something that uses auth I get an error from the api but I don't get redirected to the login page
3 replies
NNuxt
Created by TokyoStarz on 4/15/2023 in #❓・help
How to catch 401 from server routes and redirect to login page
maybe this:
export default defineNuxtRouteMiddleware(() => {
if (useError().value?.message.trim().split(' ')[0]?.slice(1,4) == '401') return navigateTo('/login');
if (!useCookie('sessionToken').value) {
return navigateTo('/login');
}
});
export default defineNuxtRouteMiddleware(() => {
if (useError().value?.message.trim().split(' ')[0]?.slice(1,4) == '401') return navigateTo('/login');
if (!useCookie('sessionToken').value) {
return navigateTo('/login');
}
});
3 replies