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

Added bluesky components for solid js #2

Open
wants to merge 3 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
4 changes: 4 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"value": "core",
"name": "core: anything core specific"
},
{
"value": "solid",
"name": "solid: anything solid specific"
},
{
"value": "docs",
"name": "docs: anything docs specific"
Expand Down
28 changes: 28 additions & 0 deletions .verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# path to a directory with all packages
storage: ../tmp/local-registry/storage

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
maxage: 60m

packages:
'**':
# give all users (including non-authenticated users) full access
# because it is a local registry
access: $all
publish: $all
unpublish: $all

# if package is not available locally, proxy requests to npm registry
proxy: npmjs

# log settings
log:
type: stdout
format: pretty
level: warn

publish:
allow_offline: true # set offline to true to allow publish offline
14 changes: 6 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
Expand All @@ -13,17 +10,18 @@
"sharedGlobals": []
},
"release": {
"projects": [
"*"
],
"projects": ["*"],
"changelog": {
"projectChangelogs": {
"renderOptions": {
"authors": false
}
}
},
"projectsRelationship": "independent"
"projectsRelationship": "independent",
"version": {
"preVersionCommand": "pnpm dlx nx run-many -t build"
}
},
"plugins": [
{
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@
"nx": "19.8.10",
"postcss": "8.4.38",
"rollup": "^4.14.0",
"solid-devtools": "^0.30.1",
"swc-loader": "0.1.15",
"tailwindcss": "3.4.3",
"tslib": "^2.3.0",
"typescript": "~5.5.2"
"typescript": "~5.5.2",
"verdaccio": "^5.0.4",
"vite-plugin-solid": "^2.10.2",
"vite-tsconfig-paths": "^5.1.3"
},
"dependencies": {
"@algolia/autocomplete-core": "^1.17.7",
Expand Down Expand Up @@ -70,9 +74,13 @@
"rollup-plugin-preserve-directives": "^0.4.0",
"shiki": "^1.22.2",
"simple-functional-loader": "^1.2.1",
"solid-js": "^1.9.3",
"swr": "^2.2.5",
"unist-util-filter": "^5.0.1",
"unist-util-visit": "^5.0.0",
"zustand": "^5.0.1"
},
"nx": {
"includedScripts": []
}
}
8 changes: 5 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bsky-react-post",
"description": "Embed Bluesky (bsky) posts in your React application. ",
"description": "Embed Bluesky (bsky) posts in your React application.",
"version": "0.1.3",
"license": "MIT",
"keywords": ["bsky", "bluesky", "react", "embed", "rsc", "client"],
Expand All @@ -16,10 +16,12 @@
"bugs": {
"url": "https://github.com/rhinobase/react-bluesky/issues"
},
"peerDependencies": {
"react": ">= 18.0.0",
"dependencies": {
"swr": "^2.2.5"
},
"peerDependencies": {
"react": ">= 18.0.0"
},
"devDependencies": {
"@atproto/api": "~0.13.15"
},
Expand Down
31 changes: 31 additions & 0 deletions packages/solid/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"target": "esnext",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"keepClassNames": true,
"externalHelpers": false,
"loose": true
},
"module": {
"type": "es6"
},
"minify": true,
"sourceMaps": false,
"exclude": [
"jest.config.ts",
".*\\.spec.tsx?$",
".*\\.test.tsx?$",
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
"./**/*.stories.tsx?$"
]
}
13 changes: 13 additions & 0 deletions packages/solid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# bsky-solid-post

bsky-solid-post allows you to embed Bluesky posts in your Solid application when using Next.js, Vite, and more.

For documentation visit [bsky-react-post.rhinobase.io](https://bsky-react-post.rhinobase.io).

## Contributing

Visit our [contributing docs](https://github.com/rhinobase/react-bluesky/blob/main/CONTRIBUTING.md).

## Credits

- This project would not have been possible without the work of [Vercel](https://github.com/vercel) on the [`react-tweet` package](https://github.com/vercel/react-tweet).
4 changes: 4 additions & 0 deletions packages/solid/cssmodule.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.module.css" {
const classes: { readonly [key: string]: string };
export default classes;
}
38 changes: 38 additions & 0 deletions packages/solid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "bsky-solid-post",
"description": "Embed Bluesky (bsky) posts in your Solid application.",
"version": "0.1.0",
"license": "MIT",
"keywords": ["bsky", "bluesky", "solid", "embed", "rsc", "client"],
"homepage": "https://bsky-react-post.rhinobase.io",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rhinobase/react-bluesky.git",
"directory": "packages/solid"
},
"bugs": {
"url": "https://github.com/rhinobase/react-bluesky/issues"
},
"peerDependencies": {
"solid-js": "^1.9.3"
},
"devDependencies": {
"@atproto/api": "~0.13.15"
},
"exports": {
".": "./client.esm.js",
"./server": "./index.esm.js",
"./api": "./api.esm.js",
"./theme.css": "./index.esm.css"
},
"typesVersions": {
"*": {
"index": ["./index.esm.d.ts"],
"api": ["./api.esm.d.ts"],
"*": []
}
}
}
22 changes: 22 additions & 0 deletions packages/solid/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "solid",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/solid/src",
"projectType": "library",
"targets": {
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
}
},
"tags": [],
"release": {
"version": {
"generatorOptions": {
"packageRoot": "dist/{projectRoot}",
"currentVersionResolver": "git-tag"
}
}
}
}
26 changes: 26 additions & 0 deletions packages/solid/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { withNx } = require("@nx/rollup/with-nx");
const preserveDirectives = require("rollup-plugin-preserve-directives");
const terser = require("@rollup/plugin-terser");

module.exports = withNx(
{
main: "./src/index.ts",
outputPath: "../../dist/packages/solid",
tsConfig: "./tsconfig.lib.json",
compiler: "swc",
format: ["esm"],
assets: [{ input: ".", output: ".", glob: "README.md" }],
external: ["react"],
},
{
input: {
index: "./src/index.ts",
client: "./src/index.client.ts",
api: "./src/api.ts",
},
output: {
preserveModules: true,
},
plugins: [preserveDirectives.default(), terser()],
},
);
28 changes: 28 additions & 0 deletions packages/solid/src/Client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Match, Show, Switch } from "solid-js";
import { EmbeddedPost, PostNotFound, PostSkeleton } from "./components";
import { usePost } from "./hooks";
import type { PostProps } from "./types";

export function Post({
fallback = <PostSkeleton />,
components,
onError,
...props
}: PostProps) {
const [post] = usePost(props);
const NotFound = components?.PostNotFound || PostNotFound;

return (
<>
<Show when={post.loading}>{fallback}</Show>
<Switch>
<Match when={post.error}>
<NotFound error={onError ? onError(post.error) : post.error} />
</Match>
<Match when={post()}>
<EmbeddedPost thread={post()} />
</Match>
</Switch>
</>
);
}
49 changes: 49 additions & 0 deletions packages/solid/src/Post.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"use server";
import type { AppBskyFeedDefs } from "@atproto/api";
import { Match, Suspense, Switch, createResource } from "solid-js";
import { fetchPost } from "./api";
import { EmbeddedPost, PostNotFound, PostSkeleton } from "./components";
import type { PostProps } from "./types";

function SuspensedPost({
components,
fetchOptions,
onError,
...config
}: PostProps) {
const NotFound = components?.PostNotFound || PostNotFound;

const fetchData = async () => {
try {
if ("apiUrl" in config) return undefined;
return await fetchPost(config, fetchOptions);
} catch (err) {
if (onError) {
return onError(err);
}
console.error(err);
throw err;
}
};

const [data] = createResource(fetchData);

return (
<Switch>
<Match when={data()}>
<EmbeddedPost thread={data() as AppBskyFeedDefs.ThreadViewPost} />
</Match>
<Match when={!data()}>
<NotFound />
</Match>
</Switch>
);
}

export function Post({ fallback = <PostSkeleton />, ...props }: PostProps) {
return (
<Suspense fallback={fallback}>
<SuspensedPost {...props} />
</Suspense>
);
}
Loading