Skip to content

Commit 9b60e4e

Browse files
committed
Initial commit
0 parents  commit 9b60e4e

File tree

14 files changed

+13321
-0
lines changed

14 files changed

+13321
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: 18
17+
cache: 'npm'
18+
- run: npm ci
19+
- run: npm run lint
20+
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: 18
28+
cache: 'npm'
29+
- run: npm ci
30+
- run: npm run build

.github/workflows/publish.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish to NPM
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: 18
15+
registry-url: https://registry.npmjs.org/
16+
- run: npm ci
17+
- run: npm run lint
18+
- run: npm run build
19+
- run: npm publish --access public
20+
env:
21+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Dependencies
2+
node_modules
3+
.pnp
4+
.pnp.js
5+
6+
# Build output
7+
dist
8+
.nuxt
9+
.output
10+
.build
11+
12+
# Logs
13+
logs
14+
*.log
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
pnpm-debug.log*
19+
lerna-debug.log*
20+
21+
# Editor directories and files
22+
.idea
23+
.DS_Store
24+
*.suo
25+
*.ntvs*
26+
*.njsproj
27+
*.sln
28+
*.sw?
29+
.vscode/*
30+
!.vscode/extensions.json
31+
!.vscode/settings.json
32+
33+
# Local env files
34+
.env
35+
.env.*
36+
!.env.example
37+
38+
# Playground
39+
playground

CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contributing to @attributech/nuxt-drupal-image
2+
3+
Thank you for considering contributing to this project! Here's how you can help.
4+
5+
## Development Setup
6+
7+
1. Clone the repository:
8+
```bash
9+
git clone https://github.com/attributech/nuxt-drupal-image.git
10+
cd nuxt-drupal-image
11+
```
12+
13+
2. Install dependencies:
14+
```bash
15+
npm install
16+
```
17+
18+
3. Build the module:
19+
```bash
20+
npm run build
21+
```
22+
23+
4. Run the playground (for testing):
24+
```bash
25+
npm run dev
26+
```
27+
28+
## Development Workflow
29+
30+
1. Create a new branch for your feature or bugfix:
31+
```bash
32+
git checkout -b feature/your-feature-name
33+
```
34+
35+
2. Make your changes and ensure they follow the project's coding style.
36+
37+
3. Run linting:
38+
```bash
39+
npm run lint
40+
```
41+
42+
4. Fix any linting issues:
43+
```bash
44+
npm run lint:fix
45+
```
46+
47+
5. Build the module to ensure it compiles correctly:
48+
```bash
49+
npm run build
50+
```
51+
52+
6. Commit your changes with a descriptive commit message.
53+
54+
7. Push your branch to GitHub:
55+
```bash
56+
git push origin feature/your-feature-name
57+
```
58+
59+
8. Create a pull request against the main branch.
60+
61+
## Pull Request Guidelines
62+
63+
- Ensure your code follows the project's coding style.
64+
- Include tests for new features or bug fixes if applicable.
65+
- Update documentation if necessary.
66+
- Keep pull requests focused on a single change.
67+
- Make sure all tests pass and there are no linting errors.
68+
69+
## Release Process
70+
71+
Releases are managed by the maintainers. The process typically involves:
72+
73+
1. Updating the version in package.json
74+
2. Creating a new GitHub release
75+
3. The GitHub Actions workflow will automatically publish to npm
76+
77+
## Code of Conduct
78+
79+
Please be respectful and considerate of others when contributing to this project.
80+
81+
## License
82+
83+
By contributing to this project, you agree that your contributions will be licensed under the project's MIT license.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 attribute GmbH
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# @attributech/nuxt-drupal-image
2+
3+
A Nuxt module for handling Drupal image styles.
4+
5+
## Features
6+
7+
- Compatible with Nuxt 2 (with Bridge) and Nuxt 3
8+
- TypeScript support
9+
- Auto-imports for the useImageUrl composable
10+
- Simplifies working with Drupal image styles
11+
12+
## Installation
13+
14+
```bash
15+
npm install @attributech/nuxt-drupal-image
16+
```
17+
18+
## Setup
19+
20+
Add the module to your `nuxt.config.ts`:
21+
22+
### Nuxt 3
23+
24+
```ts
25+
export default defineNuxtConfig({
26+
modules: [
27+
'@attributech/nuxt-drupal-image'
28+
]
29+
})
30+
```
31+
32+
### Nuxt 2 with Bridge
33+
34+
```ts
35+
import { defineNuxtConfig } from '@nuxt/bridge'
36+
37+
export default defineNuxtConfig({
38+
buildModules: [
39+
'@attributech/nuxt-drupal-image'
40+
]
41+
})
42+
```
43+
44+
## Usage
45+
46+
### useImageUrl
47+
48+
A composable for building Drupal image style URLs.
49+
50+
```ts
51+
const imageUrl = useImageUrl(imageUri, style)
52+
```
53+
54+
#### Parameters
55+
56+
- `imageUri`: The Drupal image URI (e.g., 'public://image.jpg')
57+
- `style`: The Drupal image style name (e.g., 'thumbnail', 'large')
58+
59+
#### Returns
60+
61+
- A string containing the complete URL to the styled image
62+
63+
#### Example
64+
65+
```vue
66+
<template>
67+
<img :src="imageUrl" alt="My image" />
68+
</template>
69+
70+
<script setup>
71+
const imageUri = 'public://my-image.jpg'
72+
const imageUrl = useImageUrl(imageUri, 'large')
73+
</script>
74+
```
75+
76+
#### Configuration
77+
78+
The composable uses the `serverUrl` from your Nuxt runtime config. Make sure to set this in your `nuxt.config.ts`:
79+
80+
```ts
81+
// Nuxt 3
82+
export default defineNuxtConfig({
83+
runtimeConfig: {
84+
public: {
85+
serverUrl: process.env.SERVER_URL || 'https://example.com'
86+
}
87+
}
88+
})
89+
90+
// Nuxt 2 with Bridge
91+
export default defineNuxtConfig({
92+
publicRuntimeConfig: {
93+
serverUrl: process.env.SERVER_URL || 'https://example.com'
94+
}
95+
})
96+
```
97+
98+
## Migration from existing code
99+
100+
### Migrating from util/imageUrl.js
101+
102+
If you're currently using the utility function from `util/imageUrl.js`, you can migrate to the composable as follows:
103+
104+
Before:
105+
```js
106+
import imageUrl from '@/util/imageUrl'
107+
108+
const url = imageUrl(imageUri, style, apiUrl)
109+
```
110+
111+
After:
112+
```js
113+
import { useImageUrl } from '@attributech/nuxt-drupal-image'
114+
115+
// The apiUrl is now taken from the Nuxt runtime config
116+
const url = useImageUrl(imageUri, style)
117+
```
118+
119+
## License
120+
121+
MIT

0 commit comments

Comments
 (0)