Skip to content

Commit

Permalink
Merge pull request #2 from mothership-gmbh/nuxt3
Browse files Browse the repository at this point in the history
Nuxt-3 compatibility
  • Loading branch information
niklaswolf authored Jan 3, 2023
2 parents d8d2a4e + 0653b20 commit 7b51781
Show file tree
Hide file tree
Showing 35 changed files with 10,216 additions and 1,315 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": [
"@nuxtjs/eslint-config-typescript"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"off"
]
}
}
7 changes: 4 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
name: NPM Package

on:
push:
branches:
- main
release:
types: [created]

jobs:
publish-npm:
Expand All @@ -17,6 +16,8 @@ jobs:
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run dev:prepare
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
56 changes: 55 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
# Dependencies
node_modules
.idea

# Logs
*.log*

# Temp directories
.temp
.tmp
.cache

# Yarn
**/.yarn/cache
**/.yarn/*state*

# Generated dirs
dist

# Nuxt
.nuxt
.output
.vercel_build_output
.build-*
.env
.netlify

# Env
.env

# Testing
reports
coverage
*.lcov
.nyc_output

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Intellij idea
*.iml
.idea

# OSX
.DS_Store
.AppleDouble
.LSOverride
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
2 changes: 2 additions & 0 deletions .nuxtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports.autoImport=true
typescript.includeWorkspace=true
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Add the module in your `nuxt.config.js`:
```js
{
modules: [
"@mothership-gmbh/nuxt-shopware-caching/module"
"@mothership-gmbh/nuxt-shopware-caching"
],

nuxtShopwareCaching: {
Expand All @@ -24,25 +24,21 @@ Add the module in your `nuxt.config.js`:

## Use the composable in your vue components

```js
import { useCache } from "@mothership-gmbh/nuxt-shopware-caching"

export default {
setup(props) {
const {addProductCacheTag} = useCache();
addProductCacheTag(props.productId);
}
}
```vue
<script setup>
const {addProductCacheTag} = useCache();
addProductCacheTag('1234');
</script>
```
The module will then aggregate all cache tags on the page and attach them
- in a comma-separated list to the HTTP response as a `X-Cache-Tags`-header
The module will then aggregate all cache tags on the page and attach them
- in a comma-separated list to the HTTP response as a `X-Cache-Tags`-header
- in a space-separated list to the HTTP response as a `xkey`-header (if you provided the option in your nuxt config).

Example HTTP-Response headers:
Example HTTP-Response headers:
```
X-Cache-Tags: topbar-route,base-navigation,navigation-route-e41d381d990346bebff2a736b7b12c5c,cms-page-da2ad0281b4d4fc4ae7c6f3a68700e59,product-5b5e2f24dced46cdba488c01b9c12130,product-1c150aab458940c28a30202abc404b96
```
or
or
```
X-Cache-Tags: topbar-route base-navigation navigation-route-e41d381d990346bebff2a736b7b12c5c cms-page-da2ad0281b4d4fc4ae7c6f3a68700e59 product-5b5e2f24dced46cdba488c01b9c12130 product-1c150aab458940c28a30202abc404b96
```
Expand All @@ -61,3 +57,8 @@ export declare const useCache: () => {
addLandingPageCacheTag: (landingPageId: string) => void;
};
```

## Development

- Run `npm run dev:prepare` to generate type stubs.
- Use `npm run dev` to start [playground](./playground) in development mode.
10 changes: 0 additions & 10 deletions dist/composables/useCache.d.ts

This file was deleted.

47 changes: 0 additions & 47 deletions dist/index.cjs.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.d.ts

This file was deleted.

43 changes: 0 additions & 43 deletions dist/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions dist/module/composables/useCache.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion dist/module/index.d.ts

This file was deleted.

37 changes: 0 additions & 37 deletions dist/module/module.cjs.js

This file was deleted.

4 changes: 0 additions & 4 deletions dist/module/module.d.ts

This file was deleted.

28 changes: 0 additions & 28 deletions dist/module/module.mjs

This file was deleted.

4 changes: 0 additions & 4 deletions dist/module/module/module.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions dist/module/module/plugin.d.ts

This file was deleted.

Loading

0 comments on commit 7b51781

Please sign in to comment.