Skip to content

Commit

Permalink
docs(solid-query): Add Astro Example (#7292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardeora committed Apr 17, 2024
1 parent e197965 commit 69d37f3
Show file tree
Hide file tree
Showing 15 changed files with 2,635 additions and 219 deletions.
4 changes: 4 additions & 0 deletions docs/config.json
Expand Up @@ -863,6 +863,10 @@
{
"label": "Solid Start",
"to": "framework/solid/examples/solid-start-streaming"
},
{
"label": "Astro",
"to": "framework/solid/examples/astro"
}
]
},
Expand Down
25 changes: 25 additions & 0 deletions examples/solid/astro/.gitignore
@@ -0,0 +1,25 @@
# build output
dist/
.vercel/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/
47 changes: 47 additions & 0 deletions examples/solid/astro/README.md
@@ -0,0 +1,47 @@
# Astro Starter Kit: Minimal

```sh
npm create astro@latest -- --template minimal
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure

Inside of your Astro project, you'll see the following folders and files:

```text
/
├── public/
├── src/
│ └── pages/
│ └── index.astro
└── package.json
```

Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.

There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

Any static assets, like images, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
12 changes: 12 additions & 0 deletions examples/solid/astro/astro.config.mjs
@@ -0,0 +1,12 @@
import { defineConfig } from 'astro/config'
import solidJs from '@astrojs/solid-js'
import tailwind from '@astrojs/tailwind'
import node from '@astrojs/node'
// https://astro.build/config
export default defineConfig({
output: 'server',
integrations: [solidJs(), tailwind()],
adapter: node({
mode: 'standalone',
}),
})
25 changes: 25 additions & 0 deletions examples/solid/astro/package.json
@@ -0,0 +1,25 @@
{
"name": "solid-query-astro-example",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/solid-js": "^4.1.0",
"@astrojs/tailwind": "^5.1.0",
"@astrojs/vercel": "^7.5.3",
"@astrojs/node": "^8.2.5",
"@tanstack/solid-query": "^5.30.4",
"@tanstack/solid-query-devtools": "^5.30.4",
"astro": "^4.6.1",
"solid-js": "^1.8.14",
"tailwindcss": "^3.4.1",
"typescript": "5.2.2"
}
}
9 changes: 9 additions & 0 deletions examples/solid/astro/public/favicon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions examples/solid/astro/src/components/Link.tsx
@@ -0,0 +1,20 @@
export const Link = (props: {
href: string
children: any
class?: string
}) => {
// Links doing client-side navigation
return (
<a
href={props.href}
onClick={(e) => {
e.preventDefault()
history.pushState({}, '', props.href)
window.dispatchEvent(new PopStateEvent('popstate'))
}}
class={props.class}
>
{props.children}
</a>
)
}

0 comments on commit 69d37f3

Please sign in to comment.