Skip to content

Commit e769f77

Browse files
authored
Upgrade to Nuxt Content 3 (#66)
* Upgrade to Nuxt Content 3 * Fix search and code blocks * Fix latest wiki/docs url query paths * Mark 404 errors in content pages as fatal errors * Fix description parse function modifying the page contents
1 parent 8a8c60e commit e769f77

84 files changed

Lines changed: 1266 additions & 859 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ sw.*
9292
.vercel
9393
.turbo
9494
.output
95+
.data

apps/web/app/assets/css/nuxt-content.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
}
5353
}
5454

55-
pre {
55+
.shiki {
5656
@apply p-4 mt-5 mb-6 bg-neutral-200 dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-700 rounded-lg overflow-hidden hover:overflow-auto;
5757
}
5858

apps/web/app/components/ContentLinks.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ const { mod } = useDocsMetadata();
5454
5555
const editURL = computed(
5656
() =>
57-
`https://github.com/blakesmods/web/edit/main/apps/web/content${props.page._path}.${props.page._extension}`
57+
`https://github.com/blakesmods/web/edit/main/apps/web/content${props.page.path}.${props.page.extension}`
5858
);
5959
</script>

apps/web/app/components/content/ProseCode.vue

Lines changed: 0 additions & 60 deletions
This file was deleted.

apps/web/app/components/docs/Pagination.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>
66
<UButton
77
v-if="previous"
8-
:to="previous._path"
8+
:to="previous.path"
99
class="group gap-4"
1010
size="lg"
1111
icon="i-heroicons-arrow-left"
@@ -20,7 +20,7 @@
2020
</UButton>
2121
<UButton
2222
v-if="next"
23-
:to="next._path"
23+
:to="next.path"
2424
class="ml-auto group gap-4"
2525
size="lg"
2626
icon="i-heroicons-arrow-right"
@@ -44,11 +44,9 @@ const props = defineProps({
4444
4545
const { version, isLatestVersion } = useDocsMetadata();
4646
47-
const parts = props.current._path.split("/").slice(1);
48-
4947
const { data } = await useAsyncData(
50-
"doc/" + props.current._path + "/pagination",
51-
() => queryContent(parts[0], parts[1]).findSurround(props.current._path)
48+
"docs/" + props.current.path + "/pagination",
49+
() => queryCollectionItemSurroundings("docs", props.current.path)
5250
);
5351
5452
const previous = computed(() => data.value[0]);
@@ -57,22 +55,19 @@ const next = computed(() => data.value[1]);
5755
// the latest version doesn't have the version in the url
5856
if (isLatestVersion.value) {
5957
if (previous.value) {
60-
previous.value._path = removeDocsVersionFromPath(
61-
previous.value._path,
58+
previous.value.path = removeDocsVersionFromPath(
59+
previous.value.path,
6260
version.value
6361
);
6462
}
6563
6664
if (next.value) {
67-
next.value._path = removeDocsVersionFromPath(
68-
next.value._path,
69-
version.value
70-
);
65+
next.value.path = removeDocsVersionFromPath(next.value.path, version.value);
7166
}
7267
}
7368
7469
function formatModName(document) {
75-
const modID = document._path.split("/")[isLatestVersion.value ? 2 : 3];
70+
const modID = document.path.split("/")[isLatestVersion.value ? 2 : 3];
7671
const mod = getMod(modID);
7772
return mod ? mod.name : modID;
7873
}

apps/web/app/components/docs/SidebarContent.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
v-for="document in documents[category]"
4040
class="relative pl-2 py-0.5 text-sm first:mt-2 hover:text-dimmed border-l border-neutral-300 dark:border-neutral-700"
4141
:class="{
42-
'!text-primary-500 dark:!text-primary-400 font-semibold':
43-
document._path === route.path
42+
'text-primary-500! dark:text-primary-400! font-semibold':
43+
document.path === route.path
4444
}"
45-
:to="document._path"
45+
:to="document.path"
4646
>
4747
{{ document.title }}
4848
</NuxtLink>

apps/web/app/components/global/DocsSectionList.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<NuxtLink
55
v-for="page in pages"
66
class="flex pl-2 py-0.5 md:py-0.5 text-sm border-l border-neutral-300 dark:border-neutral-700"
7-
:to="page._path"
7+
:to="page.path"
88
>
99
{{ page.title }}
1010
</NuxtLink>
@@ -17,15 +17,16 @@ const { version, mod, isLatestVersion } = useDocsMetadata();
1717
const { data } = await useAsyncData(
1818
`${mod.value?.mod_id}-${version.value}-docs-listing`,
1919
() =>
20-
queryContent("docs", version.value, mod.value?.mod_id ?? "")
21-
.only(["title", "_path"])
22-
.find()
20+
queryCollection("docs")
21+
.where("path", "LIKE", createDocsPathSQL(version.value, mod.value.mod_id))
22+
.select("title", "path")
23+
.all()
2324
);
2425
2526
const pages = computed(() =>
2627
data.value.slice(1).map(doc => {
27-
if (isLatestVersion.value && doc._path) {
28-
doc._path = removeDocsVersionFromPath(doc._path, version.value);
28+
if (isLatestVersion.value && doc.path) {
29+
doc.path = removeDocsVersionFromPath(doc.path, version.value);
2930
}
3031
3132
return doc;

apps/web/app/components/wiki/ArticleLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<NuxtLink
33
class="flex relative py-0.5 pl-2 text-sm border-l border-neutral-300 dark:border-neutral-700"
4-
:to="article._path"
4+
:to="article.path"
55
>
66
<UPopover
77
v-if="article.icon"

apps/web/app/components/wiki/Header.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<header
33
class="fixed w-full top-0 z-40 shadow backdrop-blur border-b border-neutral-200 dark:border-neutral-800 bg-neutral-100/75 dark:bg-neutral-900/75"
44
:class="{
5-
'!bg-neutral-100 dark:!bg-neutral-900': dropdown
5+
'bg-neutral-100! dark:bg-neutral-900!': dropdown
66
}"
77
>
88
<div class="container flex h-16 m-auto px-4 justify-between items-center">
@@ -61,7 +61,7 @@
6161
<div class="container text-center">
6262
You are viewing the wiki for an older version.
6363
<NuxtLink
64-
class="font-bold !text-warning hover:!underline underline-offset-4"
64+
class="font-bold text-warning! hover:underline! underline-offset-4"
6565
:to="latestURL"
6666
>
6767
View Latest ({{ getWikiLatestVersion() }})

apps/web/app/components/wiki/ListingSidebarContent.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class="w-full"
1212
trailing-icon="i-heroicons-chevron-down-20-solid"
1313
>
14-
<UAvatar class="flex-shrink-0" size="2xs" :src="mod.logo" />
14+
<UAvatar class="shrink-0" size="2xs" :src="mod.logo" />
1515
<span class="w-full text-left">
1616
{{ mod.name }}
1717
</span>
@@ -41,7 +41,7 @@
4141
class="flex items-center gap-1 truncate"
4242
>
4343
<ArticleLink :article="article" />
44-
<small class="capitalize opacity-80">- {{ article._dir }}</small>
44+
<small class="text-muted">- {{ article.category }}</small>
4545
</div>
4646
</div>
4747

0 commit comments

Comments
 (0)