Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve solid support #308

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/calm-boxes-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@content-collections/solid-start": patch
"@content-collections/vite": patch
---

Avoid type mismatches with different vite versions
6 changes: 6 additions & 0 deletions docs/quickstart/solid-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,11 @@ Now you can just import the `allPosts` collection and use it in your code.
The `allPosts` collection will contain all posts that are valid.
The `post` object will contain the `title`, `summary` and `content` fields as well as some meta information in the `_meta` field.

<Callout type="warn">
The snippet above will load all posts, including their content, on the client.
If you have a lot of posts or the content is large, you should consider loading the data on the server.
For an example of how to do this, have a look at the [SolidStart Sample](/samples/solid).
</Callout>

</div>
</div>
4 changes: 2 additions & 2 deletions packages/integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
"require": "./dist/index.cjs"
}
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/solid-start/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import contentCollectionsPlugin, { Options } from "@content-collections/vite";
import { Plugin } from "vite";

export default function remixContentCollectionsPlugin(
export default function solidStartContentCollectionsPlugin(
options?: Partial<Omit<Options, "isEnabled">>,
): Plugin {
) {
const plugin = contentCollectionsPlugin({
...(options || {}),
isEnabled(config) {
Expand All @@ -15,5 +15,5 @@ export default function remixContentCollectionsPlugin(
return {
...plugin,
name: "solidstart-content-collections",
};
} satisfies Plugin;
}
9 changes: 5 additions & 4 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function resolveConfigPath(root: string, configPath: string) {

export default function contentCollectionsPlugin(
options: Partial<Options> = {},
): Plugin {
) {
const pluginOptions = { ...defaultOptions, ...options };

let builder: Builder;
Expand All @@ -30,7 +30,7 @@ export default function contentCollectionsPlugin(
return {
name: "content-collections",

config(config) {
config(config: any) {
isEnabled = options.isEnabled ? options.isEnabled(config) : true;

// even if the plugin is disabled, we need to configure the alias
Expand Down Expand Up @@ -67,7 +67,8 @@ export default function contentCollectionsPlugin(
};
}

return configPatch;
// we cast to any here to avoid type mismatches with different vite versions
return configPatch as any;
},

async configResolved(config: any) {
Expand Down Expand Up @@ -103,5 +104,5 @@ export default function contentCollectionsPlugin(
builder.watch();
return;
},
};
} satisfies Plugin;
}
Loading
Loading