Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
Signed-off-by: xhe <[email protected]>
  • Loading branch information
xhebox committed Oct 8, 2024
0 parents commit e14e646
Show file tree
Hide file tree
Showing 49 changed files with 10,511 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
node_modules
build
public/build
api/
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build output
dist/

# 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/
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Astro Starter Kit: Basics

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

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

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554)

## 🚀 Project Structure

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

```text
/
├── public/
│ └── favicon.svg
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ └── 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).
33 changes: 33 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"organizeImports": {
"enabled": true
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "single",
"semicolons": "asNeeded"
},
"globals": ["__DEV__"]
},
"formatter": {
"enabled": true,
"formatWithErrors": true,
"indentStyle": "tab",
"indentWidth": 4,
"lineWidth": 120
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn"
}
}
},
"files": {
"ignore": ["dist", ".astro"]
}
}
60 changes: 60 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import eslint from '@eslint/js'
import eslintPluginAstro from 'eslint-plugin-astro'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import unusedImports from 'eslint-plugin-unused-imports'
import tseslint from 'typescript-eslint'

export default [
eslint.configs.recommended,
...tseslint.configs.recommended,
...eslintPluginAstro.configs.recommended,
{
plugins: {
'simple-import-sort': simpleImportSort,
'unused-imports': unusedImports,
},
rules: {
quotes: ['error', 'single'],
'simple-import-sort/imports': [
'error',
{
groups: [['.*\\u0000$'], ['^\\u0000'], ['^@?\\w'], ['^'], ['^\\.']],
},
],
'simple-import-sort/exports': 'error',
//'import/first': 'error',
//'import/newline-after-import': 'error',
//'import/no-duplicates': 'error',
'unused-imports/no-unused-imports': 'error',
'no-multiple-empty-lines': 'error',
'no-extra-semi': 'error',
'no-trailing-spaces': 'error',
'no-multi-spaces': 'error',
'linebreak-style': ['error', 'unix'],
semi: ['error', 'never'],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: 'function', next: '*' },
{ blankLine: 'always', prev: 'export', next: '*' },
{ blankLine: 'always', prev: 'multiline-var', next: '*' },
{ blankLine: 'always', prev: 'multiline-let', next: '*' },
{ blankLine: 'always', prev: 'multiline-const', next: '*' },
{ blankLine: 'always', prev: 'class', next: '*' },
{ blankLine: 'always', prev: 'function', next: '*' },
],
'comma-spacing': 'error',
'key-spacing': 'error',
'eol-last': ['error', 'always'],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/indent': [
'error',
'tab',
{
ignoredNodes: ['TSTypeParameterInstantiation'],
},
],
},
},
]
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"private": true,
"type": "module",
"workspaces": ["packages/*"],
"scripts": {
"dev": "pnpm --stream -r -parallel /^dev:/",
"release": "node scripts/release.mjs",
"lint": "biome check .",
"lint:fix": "biome check --apply ."
},
"engines": {
"node": "^18.17.1 || ^20.3.0 || >=21.0.0",
"pnpm": ">=9.0.0"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.14.1",
"tsup": "^8.3.0",
"typescript": "^5.6.2"
}
}
1 change: 1 addition & 0 deletions packages/astro-hook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
1 change: 1 addition & 0 deletions packages/astro-hook/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
36 changes: 36 additions & 0 deletions packages/astro-hook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "astro-hook",
"version": "0.0.1",
"description": "TODO:",
"author": {
"email": "TODO:",
"name": "TODO:",
"url": "TODO:"
},
"license": "MIT",
"keywords": ["astro-integration", "astro-component", "withastro", "astro", "TODO:"],
"homepage": "TODO:",
"publishConfig": {
"access": "public"
},
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": ["dist"],
"scripts": {
"dev": "pnpm run /^dev:/",
"dev:build": "tsup --watch",
"build": "tsup"
},
"type": "module",
"peerDependencies": {
"astro": "^4.9.2"
},
"dependencies": {
"astro-integration-kit": "^0.13.3"
}
}
28 changes: 28 additions & 0 deletions packages/astro-hook/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { z } from 'astro/zod'

import { defineIntegration } from 'astro-integration-kit'
import type { AstroConfig, AstroIntegrationMiddleware } from 'astro'

export const optionsSchema = z
.object({
setup: z.custom<(a: AstroConfig, b: (c: AstroIntegrationMiddleware) => void) => void>().optional(),
done: z.custom<() => void>().optional(),
})
.default({})

export default defineIntegration({
name: 'astro-hook',
optionsSchema,
setup({ options }) {
return {
hooks: {
'astro:config:setup': ({ config, addMiddleware }) => {
if (options.setup) options.setup(config, addMiddleware)
},
'astro:server:done': () => {
if (options.done) options.done()
},
},
}
},
})
10 changes: 10 additions & 0 deletions packages/astro-hook/src/integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineIntegration } from "astro-integration-kit";

export const integration = defineIntegration({
name: "package-name",
setup() {
return {
hooks: {},
};
},
});
6 changes: 6 additions & 0 deletions packages/astro-hook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["astro/tsconfigs/strict", "../../tsconfig.base.json"],
"compilerOptions": {
"jsx": "preserve"
}
}
19 changes: 19 additions & 0 deletions packages/astro-hook/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'tsup'
import { peerDependencies } from './package.json'

export default defineConfig((options) => {
const dev = !!options.watch
return {
entry: ['src/**/*.(ts|js)'],
format: ['esm'],
target: 'node18',
bundle: true,
dts: true,
sourcemap: true,
clean: true,
splitting: false,
minify: !dev,
external: [...Object.keys(peerDependencies)],
tsconfig: 'tsconfig.json',
}
})
2 changes: 2 additions & 0 deletions packages/website/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Lit libraries are required to be hoisted due to dependency issues.
public-hoist-pattern[]=*lit*
6 changes: 6 additions & 0 deletions packages/website/.typesafe-i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"baseLocale": "cn",
"esmImports": true,
"adapter": "node",
"$schema": "https://unpkg.com/[email protected]/schema/typesafe-i18n.json"
}
27 changes: 27 additions & 0 deletions packages/website/astro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import node from '@astrojs/node'
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'
import lit from '@astrojs/lit'

// https://astro.build/config
export default defineConfig({
output: 'server',
adapter: node({
mode: 'standalone',
}),
i18n: {
defaultLocale: 'en',
locales: ['es', 'zh-CN', 'en', 'fr'],
},
integrations: [
UnoCSS({
injectReset: true,
}),
lit(),
],
vite: {
optimizeDeps: {
exclude: ['oslo'],
},
},
})
Loading

0 comments on commit e14e646

Please sign in to comment.