Dog
Dog
NNuxt
Created by Dog on 2/16/2025 in #❓・help
Page appearing empty when navigating (but not directly)
On my website, https://nuxt.whitecoastrailway.com, clicking on News and Jobs in the navigation return pages with no actual content, only the header and footer (which itself is covered by the header). Using useAsyncData just errors with Cannot stringify a function, and the documentation for the sanity module says that useSanityQuery wraps useAsyncData, so there would seemingly be no point in this anyway. I'm using Sanity with the official module as my CMS to display news posts and job listings, and almost the same code is used is used on each index page. Here's the script in the jobs page: (bit messy but idc)
import type { SanityDocument } from "@sanity/client";
const router = useRouter();

const JOBS_QUERY = groq`*[
_type == "job"
&& defined(slug.current)
]|order(title, description)[0...12]{_id, title, description, department, open, slug}`;

const { data: jobs } = await useSanityQuery<SanityDocument[]>(JOBS_QUERY);

const results = ref<SanityDocument[] | null>(jobs.value ?? null);
const search = ref(decodeURIComponent(useRoute().query.search as string || ''));

watch(search, () => {
if (search.value) {
router.push({ query: { search: search.value } });
} else {
router.push({ query: {} });
}
});

const handleSearch = () => {
results.value = jobs.value?.filter((job) =>
Object.values(job).some((value) => value.toString().toLowerCase().includes(search.value.toLowerCase()))
) || [];
};
import type { SanityDocument } from "@sanity/client";
const router = useRouter();

const JOBS_QUERY = groq`*[
_type == "job"
&& defined(slug.current)
]|order(title, description)[0...12]{_id, title, description, department, open, slug}`;

const { data: jobs } = await useSanityQuery<SanityDocument[]>(JOBS_QUERY);

const results = ref<SanityDocument[] | null>(jobs.value ?? null);
const search = ref(decodeURIComponent(useRoute().query.search as string || ''));

watch(search, () => {
if (search.value) {
router.push({ query: { search: search.value } });
} else {
router.push({ query: {} });
}
});

const handleSearch = () => {
results.value = jobs.value?.filter((job) =>
Object.values(job).some((value) => value.toString().toLowerCase().includes(search.value.toLowerCase()))
) || [];
};
9 replies
NNuxt
Created by Dog on 2/16/2025 in #❓・help
[closed] Page appearing empty when navigating (but not directly)
On my website, https://nuxt.whitecoastrailway.com, clicking on News and Jobs in the navigation return pages with no actual content, only the header and footer (which itself is covered by the header). I'm using Sanity with the official module as my CMS to display news posts and job listings, and almost the same code is used is used on each index page. Here's the script in the jobs page: (bit messy but idc)
import type { SanityDocument } from "@sanity/client";
const router = useRouter();

const JOBS_QUERY = groq`*[
_type == "job"
&& defined(slug.current)
]|order(title, description)[0...12]{_id, title, description, department, open, slug}`;

const { data: jobs } = await useSanityQuery<SanityDocument[]>(JOBS_QUERY);

const results = ref<SanityDocument[] | null>(jobs.value ?? null);
const search = ref(decodeURIComponent(useRoute().query.search as string || ''));

watch(search, () => {
if (search.value) {
router.push({ query: { search: search.value } });
} else {
router.push({ query: {} });
}
});

const handleSearch = () => {
results.value = jobs.value?.filter((job) =>
Object.values(job).some((value) => value.toString().toLowerCase().includes(search.value.toLowerCase()))
) || [];
};
import type { SanityDocument } from "@sanity/client";
const router = useRouter();

const JOBS_QUERY = groq`*[
_type == "job"
&& defined(slug.current)
]|order(title, description)[0...12]{_id, title, description, department, open, slug}`;

const { data: jobs } = await useSanityQuery<SanityDocument[]>(JOBS_QUERY);

const results = ref<SanityDocument[] | null>(jobs.value ?? null);
const search = ref(decodeURIComponent(useRoute().query.search as string || ''));

watch(search, () => {
if (search.value) {
router.push({ query: { search: search.value } });
} else {
router.push({ query: {} });
}
});

const handleSearch = () => {
results.value = jobs.value?.filter((job) =>
Object.values(job).some((value) => value.toString().toLowerCase().includes(search.value.toLowerCase()))
) || [];
};
24 replies
NNuxt
Created by Dog on 1/19/2025 in #❓・help
Actual files not showing with Content v3
No description
7 replies