From 7fc97dbf0ea64bc436ff69776db6ebeb183991e4 Mon Sep 17 00:00:00 2001 From: HPCesia Date: Sun, 12 Jan 2025 03:54:02 +0800 Subject: [PATCH] init: first demo Refactor project structure and add new components - Add Navbar and SideMenu components - Update Layout and MainLayout - Add config and type definitions - Remove unused assets and components - Update README and gitignore --- .gitignore | 5 + .prettierignore | 4 + .prettierrc.cjs | 13 +++ .vscode/extensions.json | 7 +- .vscode/launch.json | 11 -- .vscode/settings.json | 9 ++ README-zh_CN.md | 3 + README.md | 49 +------- astro.config.mjs | 8 +- eslint.config.js | 59 ++++++++++ package.json | 17 ++- src/assets/astro.svg | 1 - src/assets/background.svg | 1 - src/components/Navbar.astro | 5 + src/components/SideMenu.astro | 8 ++ src/components/Welcome.astro | 209 ---------------------------------- src/config.ts | 23 ++++ src/env.d.ts | 2 + src/layouts/Layout.astro | 68 +++++++---- src/layouts/MainLayout.astro | 30 +++++ src/pages/index.astro | 12 +- src/types/config.ts | 22 ++++ tsconfig.json | 29 +++-- 23 files changed, 283 insertions(+), 312 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.cjs delete mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 README-zh_CN.md create mode 100644 eslint.config.js delete mode 100644 src/assets/astro.svg delete mode 100644 src/assets/background.svg create mode 100644 src/components/Navbar.astro create mode 100644 src/components/SideMenu.astro delete mode 100644 src/components/Welcome.astro create mode 100644 src/config.ts create mode 100644 src/env.d.ts create mode 100644 src/layouts/MainLayout.astro create mode 100644 src/types/config.ts diff --git a/.gitignore b/.gitignore index 016b59e..407f03a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,8 @@ pnpm-debug.log* # jetbrains setting folder .idea/ + +# lock files +package-lock.json +yarn.lock +pnpm-lock.yaml \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..76b517c --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +dist +node_modules +.github +.changeset \ No newline at end of file diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 0000000..752ef12 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,13 @@ +/** @type {import('prettier').Config} */ +module.exports = { + printWidth: 120, + semi: true, + singleQuote: true, + tabWidth: 2, + trailingComma: 'es5', + useTabs: false, + + plugins: [require.resolve('prettier-plugin-astro')], + + overrides: [{ files: '*.astro', options: { parser: 'astro' } }], +}; diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 22a1505..e850bf7 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,4 +1,7 @@ { - "recommendations": ["astro-build.astro-vscode"], + "recommendations": [ + "astro-build.astro-vscode", + "bradlc.vscode-tailwindcss" + ], "unwantedRecommendations": [] -} +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index d642209..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b4a577c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "editor.indentSize": "tabSize", + "editor.tabSize": 2, + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[astro]": { + "editor.defaultFormatter": "astro-build.astro-vscode" + }, +} \ No newline at end of file diff --git a/README-zh_CN.md b/README-zh_CN.md new file mode 100644 index 0000000..2e1287f --- /dev/null +++ b/README-zh_CN.md @@ -0,0 +1,3 @@ +# Astral Halo + +[English](README.md) | įŽ€äŊ“中文 \ No newline at end of file diff --git a/README.md b/README.md index ff19a3e..995da92 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,3 @@ -# Astro Starter Kit: Basics +# Astral Halo -```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/ -│ ├── layouts/ -│ │ └── Layout.astro -│ └── pages/ -│ └── index.astro -└── package.json -``` - -To learn more about the folder structure of an Astro project, refer to [our guide on project structure](https://docs.astro.build/en/basics/project-structure/). - -## 🧞 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). +English | [įŽ€äŊ“中文](README-zh_CN.md) \ No newline at end of file diff --git a/astro.config.mjs b/astro.config.mjs index 8d7977c..4662b86 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,6 +1,10 @@ // @ts-check // @ts-check -import { defineConfig } from 'astro/config'; +import { defineConfig } from "astro/config"; // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ + site: "https://astral-halo.netilify.app/", + base: "/", + trailingSlash: "always", +}); diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..3961a84 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,59 @@ +import astroEslintParser from 'astro-eslint-parser'; +import eslintPluginAstro from 'eslint-plugin-astro'; +import globals from 'globals'; +import js from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import typescriptParser from '@typescript-eslint/parser'; + +export default [ + js.configs.recommended, + ...eslintPluginAstro.configs['flat/recommended'], + ...tseslint.configs.recommended, + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, + }, + { + files: ['**/*.astro'], + languageOptions: { + parser: astroEslintParser, + parserOptions: { + parser: '@typescript-eslint/parser', + extraFileExtensions: ['.astro'], + }, + }, + }, + { + files: ['**/*.{js,jsx,astro}'], + rules: { + 'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'], + }, + }, + { + // Define the configuration for `