@shopbite-de/storefront 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yaml +33 -0
- package/.gitignore +5 -0
- package/CLAUDE.md +4 -0
- package/app/assets/css/main.css +3 -0
- package/app/composables/useThemePreset.ts +16 -7
- package/modules/theme.ts +8 -0
- package/nuxt.config.ts +3 -1
- package/package.json +1 -1
- package/test/layer/nuxt.config.ts +8 -0
|
@@ -124,6 +124,39 @@ jobs:
|
|
|
124
124
|
- name: Unit tests
|
|
125
125
|
run: pnpm test:unit
|
|
126
126
|
|
|
127
|
+
layer-build:
|
|
128
|
+
name: Build as a layer
|
|
129
|
+
needs: [setup]
|
|
130
|
+
timeout-minutes: 10
|
|
131
|
+
runs-on: ubuntu-latest
|
|
132
|
+
steps:
|
|
133
|
+
- uses: actions/checkout@v7
|
|
134
|
+
|
|
135
|
+
- uses: pnpm/action-setup@v6
|
|
136
|
+
with:
|
|
137
|
+
version: 12.9.1
|
|
138
|
+
|
|
139
|
+
- uses: actions/setup-node@v7
|
|
140
|
+
with:
|
|
141
|
+
node-version: '24'
|
|
142
|
+
|
|
143
|
+
- name: Restore workspace from cache
|
|
144
|
+
uses: actions/cache/restore@v6
|
|
145
|
+
with:
|
|
146
|
+
path: |
|
|
147
|
+
~/.local/share/pnpm/store
|
|
148
|
+
node_modules
|
|
149
|
+
.nuxt
|
|
150
|
+
.output
|
|
151
|
+
key: workspace-${{ runner.os }}-${{ github.sha }}
|
|
152
|
+
|
|
153
|
+
# test/layer extends the storefront like a shop does; imports that only
|
|
154
|
+
# resolve inside the storefront itself break here (2.0.1)
|
|
155
|
+
- name: Build test/layer
|
|
156
|
+
env:
|
|
157
|
+
NODE_OPTIONS: "--max_old_space_size=4096"
|
|
158
|
+
run: pnpm nuxt build test/layer
|
|
159
|
+
|
|
127
160
|
a11y:
|
|
128
161
|
name: Accessibility (${{ matrix.preset }})
|
|
129
162
|
# no test customer needed: the repository secrets (Store API key) suffice
|
package/.gitignore
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -153,6 +153,10 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
|
|
|
153
153
|
- `server/plugins/ai-crawlers.ts` adds two named robots.txt groups via the `robots:config` hook (#403): AI search/assistant bots and AI training bots (lists with sources in `server/utils/aiCrawlers.ts`), toggled by `runtimeConfig.aiCrawlers.search`/`.training`. A crawler matching a named group ignores `*`, so allowed groups repeat the `robots.disallow` paths.
|
|
154
154
|
- Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`; `alternateNames` lists other names the shop is listed under, for the Restaurant schema `alternateName` and `/llms.txt`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
|
|
155
155
|
|
|
156
|
+
### Layer imports
|
|
157
|
+
|
|
158
|
+
Shops extend the storefront as a Nuxt layer, so paths must resolve from the storefront itself: `~`, `@` and `#shared` point to the shop's folders there. App code imports nothing from `shared/` (only types; a relative import breaks the Nitro server bundle), so `modules/theme.ts` passes what the app needs through runtime config (`shopBite.themePresets`). Files in `nuxt.config.ts` use `fileURLToPath(new URL("./…", import.meta.url))` (`css`, local modules). `main.css` lists `@source "../.."`, because Tailwind's automatic detection only scans the shop. `test/layer/` is a minimal shop (`extends: ["../.."]`) that the CI job `layer-build` builds (`pnpm nuxt build test/layer`); 2.0.0 broke every shop because only the storefront itself was built.
|
|
159
|
+
|
|
156
160
|
### Testing setup
|
|
157
161
|
|
|
158
162
|
Two Vitest projects in `vitest.config.ts`:
|
package/app/assets/css/main.css
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
2
|
|
|
3
3
|
@source "../../../content/**/*";
|
|
4
|
+
/* the storefront's own components: Tailwind's automatic detection only
|
|
5
|
+
scans the shop that extends this layer (2.0.1) */
|
|
6
|
+
@source "../..";
|
|
4
7
|
|
|
5
8
|
@theme {
|
|
6
9
|
/* This is important because apple devices will zoom in when the font size is below 16px */
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
type PresetInfo = {
|
|
2
|
+
menuView: "bon" | "bonPhoto" | "listPhoto";
|
|
3
|
+
colorMode: "light" | "dark";
|
|
4
|
+
};
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* The active style preset (#439, #445): `runtimeConfig.public.shopBite
|
|
5
8
|
* .themePreset` (`NUXT_PUBLIC_SHOP_BITE_THEME_PRESET`), by default the
|
|
6
|
-
* `shopBite.preset` of the build
|
|
9
|
+
* `shopBite.preset` of the build, else `trattoria`. modules/theme.ts puts
|
|
10
|
+
* the menu view and colour mode of every preset into the runtime config.
|
|
7
11
|
*/
|
|
8
12
|
export function useThemePreset() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
13
|
+
const shopBite = useRuntimeConfig().public.shopBite as
|
|
14
|
+
| { themePreset?: string; themePresets?: Record<string, PresetInfo> }
|
|
15
|
+
| undefined;
|
|
16
|
+
const presets = shopBite?.themePresets ?? {};
|
|
17
|
+
const configured = shopBite?.themePreset ?? "";
|
|
18
|
+
const preset = Object.hasOwn(presets, configured) ? configured : "trattoria";
|
|
19
|
+
const { menuView, colorMode } = presets[preset] ?? {
|
|
20
|
+
menuView: "bon",
|
|
21
|
+
colorMode: "light",
|
|
22
|
+
};
|
|
14
23
|
return { preset, menuView, colorMode };
|
|
15
24
|
}
|
package/modules/theme.ts
CHANGED
|
@@ -100,6 +100,14 @@ export default defineNuxtModule<ShopBiteThemeOptions>({
|
|
|
100
100
|
>;
|
|
101
101
|
const shopBite = (publicConfig.shopBite ??= {}) as Record<string, unknown>;
|
|
102
102
|
shopBite.themePreset = name;
|
|
103
|
+
// what the app needs to know about each preset, so app code imports
|
|
104
|
+
// nothing from shared/ (a layer import would resolve in the shop)
|
|
105
|
+
shopBite.themePresets = Object.fromEntries(
|
|
106
|
+
presets.map((preset) => [
|
|
107
|
+
preset.name,
|
|
108
|
+
{ menuView: preset.menuView, colorMode: preset.colorMode },
|
|
109
|
+
]),
|
|
110
|
+
);
|
|
103
111
|
// optional logo URL instead of public/light|dark/Logo.png
|
|
104
112
|
shopBite.logoUrl ??= "";
|
|
105
113
|
|
package/nuxt.config.ts
CHANGED
|
@@ -172,7 +172,9 @@ export default defineNuxtConfig({
|
|
|
172
172
|
preset: "trattoria",
|
|
173
173
|
},
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
// Absolute: `~` would point to the app/ folder of a shop extending this
|
|
176
|
+
// layer, which may have no main.css (2.0.1).
|
|
177
|
+
css: [fileURLToPath(new URL("./app/assets/css/main.css", import.meta.url))],
|
|
176
178
|
|
|
177
179
|
fonts: {
|
|
178
180
|
defaults: {
|
package/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// A minimal shop that extends the storefront like the real shops do (La
|
|
2
|
+
// Fattoria, quickstart, lead demos). CI builds it to catch imports that only
|
|
3
|
+
// resolve inside the storefront itself, e.g. the `#shared` alias, which in a
|
|
4
|
+
// layer points to the shop's shared/ folder (2.0.1).
|
|
5
|
+
export default defineNuxtConfig({
|
|
6
|
+
extends: ["../.."],
|
|
7
|
+
shopBite: { preset: "grill" },
|
|
8
|
+
});
|