content icon indicating copy to clipboard operation
content copied to clipboard

v3 Feedback

Open harlan-zw opened this issue 1 year ago • 2 comments

Hi there, I saw the v3 was recently published so I thought I'd have a play around.

Instead of spamming several issues, I thought I'd make this one to track. I'm not sure if it's in a state where you're welcoming issues / PRs so let me know how I can help.

  • Config is currently only resolving through root path, we should ideally support the srcDir (/app in nuxt v4). Ideally logic should be similar to @nuxtjs/mdc see (https://github.com/nuxt-modules/mdc/blob/main/src/module.ts#L106)
  • It does not seem possible to load in the content dir with your own prefix as the default collection overrides it
  • Using a collection name with a - in it throws an error, this is due to a SQL error (ERROR Cannot start nuxt: near "-": syntax error)
  • SQL errors aren't exposed properly as above, the SQL should be returned so the user can debug on their end.
  • Using the source as an object is a bit confusing, I think it would be clearer if paths was include and was defaulted to **/*.md for page types
  • For Nuxt SEO I am pulling content from each individual github repo, it's not possible for me to set these up under one collection which makes querying nav quite difficult. It seems like a collection should support multiple sources or we should be able to query all collections easily.
  • Inline code such as `<div>hello world</div>` is being converted to ProseCode instead of ProseInlineCode. This seems to be known given the component override.
  • queryCollectionNavigation appears to be generating nested items when they shouldn't be only sometimes

Image

I'll add more items as I continue with the integration however please feel free to close once reviewed.

harlan-zw avatar Oct 17 '24 04:10 harlan-zw

Thanks @harlan-zw for the feedback.

Config is currently only resolving through root path, we should ideally support the srcDir (/app in nuxt v4). Ideally logic should be similar to @nuxtjs/mdc see (https://github.com/nuxt-modules/mdc/blob/main/src/module.ts#L106)

V3 is not supporting the layers yet, but it will soon. As for the config directory, I believe rootDir is better place config file. Like content directory itself, this file is not part of the application.

It does not seem possible to load in the content dir with your own prefix as the default collection overrides it

I think you are talking about prefix in colelction source

defineCollection({
  type: 'page',
  source: {
    path: '**',
    prefix: '/my-prefix'
  }
})

Also, there is no default collection in v3, only if content.config.ts is not found.

Inline code such as <div>hello world</div> is being converted to ProseCode instead of ProseInlineCode. This seems to be known given the component override.

Like you said, this is a known breaking change in V3. It was a breaking change in MDC module, but in Content V2 we had a workaround to prevent it.

queryCollectionNavigation appears to be generating nested items when they shouldn't be only sometimes

Could you share your directory structure for this one? queryCollectionNavigation logic is same is old navigation login

For Nuxt SEO I am pulling content from each individual github repo, it's not possible for me to set these up under one collection which makes querying nav quite difficult. It seems like a collection should support multiple sources or we should be able to query all collections easily.

Thanks for raising concern about multi-source. Querying all collections in a single query is not an ideal solution for this, specially when collections might have different schemas, querying all at once might result in an exception.

Correct me if I'm wrong, but I think you don't need multi-source to achieve your goal in NuxtSEO docs. As I see in the docs, each module docs have its own separate navigation and pages.

As for command palette search, search indexes can generate for different module docs and add to palette.

farnabaz avatar Oct 18 '24 14:10 farnabaz

Hi, I also was pleasantly surprise on the progress of version 3 and the progress on the documentation site.

I was just trying to adopt it as a PoC for my nuxt content v2 sites and I stumbled over something. I have sites where my content is only available for authenticated users. In v2 I needed to write code like this to inject the cookie when fetching content because to my knowledge queryContent() never really supported passing headers.

const params = `?_params={"first":true,"where":[{"_path":"${myRoute.value}"}],"sort":[{"_file":1,"$numeric":true}]}`
const headers = { ...useRequestHeaders(['cookie']) }
const page = await $fetch('/api/_content/query' + params, {
  headers,
  method: 'GET',
})

In the new version it seems again it is not possible to pass headers when querying. It would be a really nice feature because content might be available only to certain users and not public.

I am also not sure how access to authenticated content is handled when this is used: WASM SQLite in Browser, can I just in the middleware allow access to /api/database.json if the user is authorized?

oripka avatar Oct 18 '24 18:10 oripka

Thanks for your help @farnabaz, I was able to get it all up and running so I'm going to close this issue.

My only concern is the SSR time in Cloudflare pages (1-3s) but this can be investigated separately.

harlan-zw avatar Nov 01 '24 04:11 harlan-zw