initial commit

This commit is contained in:
Timothy Yin 2024-11-15 16:42:17 +08:00
commit 8a905af78b
15 changed files with 8062 additions and 0 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

21
.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
node_modules
*.log
.nuxt
nuxt.d.ts
.output
.data
.env
package-lock.json
framework
dist
.DS_Store
# Yarn
.yarn/cache
.yarn/*state*
# Local History
.history
# VSCode
.vscode/

2
.npmrc Normal file
View File

@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false

1
.nuxtrc Normal file
View File

@ -0,0 +1 @@
typescript.includeWorkspace = true

View File

@ -0,0 +1,5 @@
export default defineAppConfig({
myLayer: {
name: 'My amazing Nuxt layer (overwritten)'
}
})

View File

@ -0,0 +1,4 @@
export default defineNuxtConfig({
extends: ['..'],
modules: ['@nuxt/eslint']
})

73
README.md Normal file
View File

@ -0,0 +1,73 @@
# Nuxt Layer Starter
Create Nuxt extendable layer with this GitHub template.
## Setup
Make sure to install the dependencies:
```bash
pnpm install
```
## Working on your layer
Your layer is at the root of this repository, it is exactly like a regular Nuxt project, except you can publish it on NPM.
The `.playground` directory should help you on trying your layer during development.
Running `pnpm dev` will prepare and boot `.playground` directory, which imports your layer itself.
## Distributing your layer
Your Nuxt layer is shaped exactly the same as any other Nuxt project, except you can publish it on NPM.
To do so, you only have to check if `files` in `package.json` are valid, then run:
```bash
npm publish --access public
```
Once done, your users will only have to run:
```bash
npm install --save your-layer
```
Then add the dependency to their `extends` in `nuxt.config`:
```ts
defineNuxtConfig({
extends: 'your-layer'
})
```
## Development Server
Start the development server on http://localhost:3000
```bash
pnpm dev
```
## Production
Build the application for production:
```bash
pnpm build
```
Or statically generate it with:
```bash
pnpm generate
```
Locally preview production build:
```bash
pnpm preview
```
Checkout the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

14
app.config.ts Normal file
View File

@ -0,0 +1,14 @@
export default defineAppConfig({
myLayer: {
name: 'Hello from Nuxt layer'
}
})
declare module '@nuxt/schema' {
interface AppConfigInput {
myLayer?: {
/** Project name */
name?: string
}
}
}

3
app.vue Normal file
View File

@ -0,0 +1,3 @@
<template>
<HelloWorld />
</template>

10
components/HelloWorld.vue Normal file
View File

@ -0,0 +1,10 @@
<script setup lang="ts">
const { myLayer } = useAppConfig()
</script>
<template>
<div>
<h1>Hello World!</h1>
<pre>{{ myLayer }}</pre>
</div>
</template>

3
eslint.config.js Normal file
View File

@ -0,0 +1,3 @@
import withNuxt from './.playground/.nuxt/eslint.config.mjs'
export default withNuxt()

4
nuxt.config.ts Normal file
View File

@ -0,0 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true }
})

22
package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "my-nuxt-layer",
"type": "module",
"version": "0.0.1",
"main": "./nuxt.config.ts",
"scripts": {
"dev": "nuxi dev .playground",
"dev:prepare": "nuxt prepare .playground",
"build": "nuxt build .playground",
"generate": "nuxt generate .playground",
"preview": "nuxt preview .playground",
"lint": "eslint ."
},
"devDependencies": {
"@nuxt/eslint": "latest",
"eslint": "^9.14.0",
"nuxt": "^3.14.159",
"typescript": "^5.6.3",
"vue": "latest"
},
"packageManager": "pnpm@9.13.2+sha512.88c9c3864450350e65a33587ab801acf946d7c814ed1134da4a924f6df5a2120fd36b46aab68f7cd1d413149112d53c7db3a4136624cfd00ff1846a0c6cef48a"
}

7885
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

3
tsconfig.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "./.playground/.nuxt/tsconfig.json"
}