@shopbite-de/storefront 1.29.0 → 1.30.0

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.
Files changed (50) hide show
  1. package/.env.example +9 -0
  2. package/CLAUDE.md +4 -1
  3. package/app/components/Category/Listing.vue +1 -0
  4. package/app/components/Home/Faq.vue +58 -0
  5. package/app/components/Home/Highlights.vue +1 -0
  6. package/app/components/Product/Card.vue +46 -10
  7. package/app/components/Product/CardDietBadges.vue +7 -13
  8. package/app/components/Product/CrossSelling.vue +18 -2
  9. package/app/components/Product/DeselectIngredient.vue +10 -3
  10. package/app/components/Product/Detail.vue +33 -2
  11. package/app/components/Product/QuickView.vue +20 -1
  12. package/app/composables/useMenuSectionSchema.ts +21 -8
  13. package/app/composables/useProductCrossSelling.ts +1 -0
  14. package/app/composables/useProductQuickView.ts +151 -9
  15. package/app/composables/useRestaurantSchema.ts +40 -3
  16. package/app/composables/useShareLink.ts +47 -0
  17. package/app/composables/useTopSellers.ts +4 -1
  18. package/app/pages/index.vue +7 -0
  19. package/app/types/Association.d.ts +2 -0
  20. package/app/utils/product.ts +28 -0
  21. package/app/utils/productUrl.ts +87 -0
  22. package/app/utils/schema.ts +82 -1
  23. package/app/utils/seo.ts +13 -0
  24. package/content/index.yml +18 -0
  25. package/content.config.ts +13 -0
  26. package/docs/notes/2026-10-05-issue-289-product-deep-links.md +28 -0
  27. package/docs/notes/2026-10-05-issue-400-menu-item-ingredients-diet.md +18 -0
  28. package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +21 -0
  29. package/docs/notes/2026-10-05-issue-402-llms-txt.md +17 -0
  30. package/docs/notes/2026-10-05-issue-403-ai-crawlers.md +15 -0
  31. package/docs/notes/2026-10-05-issue-404-faq.md +21 -0
  32. package/docs/notes/2026-10-05-issue-411-quick-view-share.md +22 -0
  33. package/nuxt.config.ts +20 -0
  34. package/package.json +1 -1
  35. package/server/api/listing/[categoryId].get.ts +3 -0
  36. package/server/api/product/[productId]/cross-selling.get.ts +2 -1
  37. package/server/plugins/ai-crawlers.ts +27 -0
  38. package/server/routes/llms.txt.ts +213 -0
  39. package/server/utils/aiCrawlers.ts +79 -0
  40. package/server/utils/llmsTxt.ts +207 -0
  41. package/test/nuxt/HomeFaq.test.ts +34 -0
  42. package/test/nuxt/ProductCrossSelling.test.ts +20 -0
  43. package/test/nuxt/ProductDeselectIngredient.test.ts +34 -0
  44. package/test/nuxt/useShareLink.test.ts +76 -0
  45. package/test/unit/aiCrawlers.spec.ts +48 -0
  46. package/test/unit/llmsTxt.spec.ts +149 -0
  47. package/test/unit/product.spec.ts +20 -0
  48. package/test/unit/productUrl.spec.ts +90 -0
  49. package/test/unit/schema.spec.ts +123 -0
  50. package/test/unit/seo.spec.ts +13 -0
package/content.config.ts CHANGED
@@ -88,6 +88,19 @@ export default defineContentConfig({
88
88
  // (#388); the components carry German defaults.
89
89
  menu: createBaseSchema().partial().optional(),
90
90
  highlights: createBaseSchema().partial().optional(),
91
+ // Questions and answers above the call to action, also emitted as
92
+ // FAQPage JSON-LD and in /llms.txt (#404). Plain text answers.
93
+ faq: createBaseSchema()
94
+ .partial()
95
+ .extend({
96
+ items: z.array(
97
+ z.object({
98
+ question: z.string().nonempty(),
99
+ answer: z.string().nonempty(),
100
+ }),
101
+ ),
102
+ })
103
+ .optional(),
91
104
  gallery: createBaseSchema()
92
105
  .extend({
93
106
  images: z.array(
@@ -0,0 +1,28 @@
1
+ # Issue #289: product deep links instead of product pages
2
+
3
+ As of 2026-10-05, branch `feature/289-product-deep-links`. Scope changed with Lirim: no product detail pages (a restaurant product is name, description, price: thin content next to the category page). The quick view deep link `/<category>/?produkt=<number>` is the product URL; its source of truth is the product SEO URL in Shopware, set by the ShopBite plugin (shopware-plugin#28).
4
+
5
+ ## Shopware SEO URL template
6
+
7
+ Lirim's template, verified on the demo (preview API and after indexing):
8
+
9
+ ```twig
10
+ {% set main = product.mainCategories|first %}{% set cat = main ? main.category : product.categories|first %}{% for p in (cat.translated.breadcrumb ?? [])|slice(1) %}{{ p }}/{% endfor %}?produkt={{ product.productNumber|url_encode|raw }}
11
+ ```
12
+
13
+ - `slice(1)` matches the demo's category template (`category.seoBreadcrumb` → `Speisekarte/Pizza/`, incl. slugs such as `Getraenke`); `slice(2)` gives `Pizza/…`, which does not exist. Shops with a prefixed category template (La Fattoria `c/…`) need the prefix: the plugin derives it.
14
+ - The product number must be `|url_encode|raw`: the SEO escaper slugifies variables, `LF-21-groß` became `LF-21-gross`, which the quick view cannot find. Encoded it is `LF-21-gro%C3%9F`, which the router decodes.
15
+ - `seoBreadcrumb`/`seoCategory` are not available in the product template; the preview API renders main products only, so variants are only visible after indexing.
16
+ - **The demo backend now runs this template** (set via Admin API for verification, both `frontend.detail.page` and `store-api.product.detail`, reindexed).
17
+
18
+ ## Implementation
19
+
20
+ - `app/utils/productUrl.ts`: `productDeepLink(product, categoryPath?)` takes the canonical product SEO URL if its query has `produkt`, otherwise category SEO URL + `?produkt=<number>`; `PRODUCT_QUICK_VIEW_PARAM` moved there.
21
+ - Listing (`server/api/listing`), top sellers and `/llms.txt` request `seoUrls` (`seo_url: seoPathInfo, isCanonical`, header `sw-include-seo-urls`).
22
+ - `MenuItem.url` in the category schema, dish links in `/llms.txt`.
23
+ - Product card: with `href`, the name is an `<a>` stretched over the card (`after:absolute after:inset-0`); the article drops `role="button"`/tabindex, the focus ring moves to `has-[a:focus-visible]`. A plain click is prevented and bubbles to the card's `select` (quick view in place, no page load); a modified click opens the link. The wishlist button got `z-10` to stay above the stretched link. Without `href` (e.g. search) the card behaves as before. Top seller cards link only when the product SEO URL is a deep link (no category known on the home page).
24
+ - `useProductQuickView`: a number that is not in the list is loaded in the browser (`readProduct`, `sw-inheritance`), and the quick view opens with it; `ProductDetail` loads the variant id, whose configurator preselects its options.
25
+
26
+ ## Verification
27
+
28
+ Production build against the demo: card `<a href>`s, `MenuItem.url` and `/llms.txt` links (fallback URLs before the template change, SEO URLs after). Playwright on mobile: card click opens the quick view without a page load; Enter on the focused link opens it; Ctrl+click opens a new tab without the quick view; the wishlist button stays clickable; `?produkt=LF-21-gro%C3%9F` opens "Pizza Margherita" with "Groß 40 cm" selected; no console errors. Card look unchanged (link inherits colour, no underline). All unit + nuxt tests, typecheck, ESLint green.
@@ -0,0 +1,18 @@
1
+ # Issue #400: ingredients and diet in the MenuItem schema
2
+
3
+ As of 2026-10-05, branch `feature/400-menu-item-ingredients-diet`. Part of the AI visibility issues #400–#404.
4
+
5
+ ## Finding
6
+
7
+ On www.pizzeria-lafattoria.de, `/c/Pizza/` carried 29 `MenuItem`s, but only 4 had a `description`: the ingredients live in the `Hauptzutaten` property group, not in the product description. No item said whether it is vegetarian or vegan. AI assistants answering "what is on it / is it vegetarian" had nothing to go on.
8
+
9
+ ## Implementation
10
+
11
+ - `buildMenuSectionSchema` takes `ingredients` and `diets` per item. The description falls back to the ingredients joined with ", " when the product has none; a product description always wins.
12
+ - `suitableForDiet`: `VegetarianDiet` for `Vegetarisch: Ja`, `VegetarianDiet` + `VeganDiet` for `Vegan: Ja` (vegan dishes are vegetarian; shops often flag only `Vegan`).
13
+ - `hasYesOption`/`getDiets` moved to `app/utils/product.ts`; `CardDietBadges.vue` uses them, so badges and schema share one rule.
14
+ - No extra request: `sortedProperties` is part of the listing the page loads anyway.
15
+
16
+ ## Verification
17
+
18
+ Production build against the demo backend: `/Speisekarte/Pizza/` 14/14 items with description, 5 with `suitableForDiet`; Salate 5/5 and 2; Nudeln 11/11 and 5. Unit, nuxt tests, typecheck and ESLint green.
@@ -0,0 +1,21 @@
1
+ # Issue #401: ordering, delivery area, geo and payment in the Restaurant schema
2
+
3
+ As of 2026-10-05, branch `feature/401-restaurant-schema-ordering`. Part of the AI visibility issues #400–#404.
4
+
5
+ ## Decisions (agreed with Lirim)
6
+
7
+ - Delivery areas, coordinates and reservations come from `runtimeConfig.public.site` (env), like the address. Moving them to the plugin configuration is #298.
8
+ - Payment methods are read live from the Store API (`readPaymentMethod`, `onlyAvailable`, `includes` in the POST body, #312): one extra request when the home page renders on the server.
9
+
10
+ ## Implementation
11
+
12
+ - `buildRestaurantSchema` adds `geo` (only with both coordinates; env values may be numbers or strings), `areaServed`, `acceptsReservations` (`false` is kept), `paymentAccepted` (names joined with ", "), `currenciesAccepted` and `potentialAction`.
13
+ - `OrderAction` only when the plugin reports `isCheckoutEnabled`. Target is `/speisekarte` (the same URL as `hasMenu`; it redirects to the menu category). `deliveryMethod`: `OnSitePickup` when an address street is set, `DeliveryModeOwnFleet` when delivery areas are set. Shopware shipping methods do not tell pickup and delivery apart (the demo has only `shipping_standard`), so they are not used.
14
+ - `NUXT_PUBLIC_SITE_DELIVERY_AREAS` is comma-separated; a JSON array (parsed by Nuxt) works too.
15
+ - Payment method names are shown as configured in Shopware (demo: "Nachnahme"); shops should name them the way customers say it ("Barzahlung bei Lieferung").
16
+
17
+ ## Verification
18
+
19
+ Production build against the demo backend with the new env variables: the home page `Restaurant` node carries `geo`, both delivery areas, `acceptsReservations: true`, `paymentAccepted: "Nachnahme"`, `currenciesAccepted: "EUR"` and the `OrderAction` with pickup and own delivery. Without the new variables only `paymentAccepted`, `currenciesAccepted` and `potentialAction` (without `deliveryMethod`) are added. Unit + nuxt tests, typecheck, ESLint green.
20
+
21
+ Docs: homepage branch `docs/401-restaurant-schema-ordering` (configuration page, DE/EN), including the note that `NUXT_PUBLIC_SITE_CUISINE` is a cuisine name: La Fattoria sets `italienische`, which produces "italienische in Obertshausen" in its meta description.
@@ -0,0 +1,17 @@
1
+ # Issue #402: /llms.txt
2
+
3
+ As of 2026-10-05, branch `feature/402-llms-txt`. Part of the AI visibility issues #400–#404.
4
+
5
+ ## Implementation
6
+
7
+ - `server/routes/llms.txt.ts` gathers the data, `server/utils/llmsTxt.ts` builds the Markdown (pure, unit-tested). The route lives in the layer, so every shop extending the storefront gets it.
8
+ - Sources: `runtimeConfig.public.site` (name, description, address, phone, cuisine, delivery areas from #401), the ShopBite plugin routes (business hours, holidays, config: checkout enabled, delivery time), `/context` (currency), the menu navigation (`menuCategoryId`, with SEO URLs) and all main products via `/product` (100 per page, at most 10 pages, `includes` in the POST body, #312). Each source is optional: `Promise.allSettled`, a failed request drops its section.
9
+ - Products are grouped by their directly assigned `categoryIds` (extras without category are not listed). Products with variants show "ab <cheapest price>". Ingredients and diets reuse `getMainIngredients`/`getDiets` (#400).
10
+ - Sorting: the `/product` route ignored `sort` by name, so items are sorted in code (German locale, numeric).
11
+ - Content pages come from the `landingpages` collection; pages that `robots.txt` blocks (La Fattoria's legal pages) are filtered with `getPathRobotConfig`.
12
+ - `swr: 3600` route rule. On non-indexable sites the robots module already sends `X-Robots-Tag: noindex, nofollow` for this route, so no own header is needed.
13
+ - `splitList` moved to `app/utils/seo.ts` (shared with `useRestaurantSchema`).
14
+
15
+ ## Verification
16
+
17
+ Production build against the demo backend: `/llms.txt` 200, `text/markdown; charset=utf-8`, 120 lines / 5 KB with 9 menu sections, "ab" prices for pizzas, ingredients and diets; with `NUXT_SITE_INDEXABLE=false` the response carries `X-Robots-Tag: noindex, nofollow`. Unit + nuxt tests, typecheck, ESLint green.
@@ -0,0 +1,15 @@
1
+ # Issue #403: AI crawler policy in robots.txt
2
+
3
+ As of 2026-10-05, branch `feature/403-ai-crawler-robots`. Part of the AI visibility issues #400–#404.
4
+
5
+ ## Implementation
6
+
7
+ - `runtimeConfig.aiCrawlers` (server-only): `search` and `training`, both `true` by default (the previous behaviour, now explicit). Env: `NUXT_AI_CRAWLERS_SEARCH`, `NUXT_AI_CRAWLERS_TRAINING`.
8
+ - `server/plugins/ai-crawlers.ts` hooks `robots:config` of `@nuxtjs/robots` (6.2), which runs at runtime for robots.txt and for the per-request `X-Robots-Tag`. A build-time `robots.groups` entry could not read the env. The hook gets a fresh copy of the configured groups on every call, so pushing groups does not accumulate.
9
+ - `server/utils/aiCrawlers.ts` (pure, unit-tested) builds one group per kind. A crawler matching a named group ignores the `*` group, so an allowed group repeats the `*` disallow paths (La Fattoria's legal pages stay blocked for AI bots too).
10
+ - User agents verified on the operators' pages on 2026-10-05 (sources in the file header). `Google-Extended` and `Applebot-Extended` are control tokens, not crawlers; Google AI Overviews follow Googlebot, not `Google-Extended`.
11
+ - Non-indexable sites (demo) never reach the hook: the module answers with `Disallow: /` before resolving groups.
12
+
13
+ ## Verification
14
+
15
+ Production build against the demo backend: default robots.txt lists both groups with `Allow: /` plus the three disallows; `NUXT_AI_CRAWLERS_TRAINING=false` gives the training group `Disallow: /` and a GPTBot request gets `X-Robots-Tag: noindex, nofollow`; `NUXT_SITE_INDEXABLE=false` keeps the single `Disallow: /`. Unit tests, typecheck, ESLint green.
@@ -0,0 +1,21 @@
1
+ # Issue #404: FAQ section with FAQPage schema
2
+
3
+ As of 2026-10-05, branch `feature/404-faq`. Last of the AI visibility issues #400–#404.
4
+
5
+ ## Decisions
6
+
7
+ - **Data:** optional `faq` (headline, title, description, `items` of question/answer) in the `home` collection (`content/index.yml`), next to the other home sections. Shops without `faq` render nothing; La Fattoria has its own `index.yml`, so nothing changes there until it adds questions.
8
+ - **Place:** home page, above the closing CTA. `/zahlung-und-versand` stays a Markdown page.
9
+ - **Markup:** native `<details>`/`<summary>` instead of `UAccordion`. Reka's accordion unmounts closed panels by default, so the answers would be missing from the SSR HTML that crawlers read; `<details>` keeps them in the markup, is keyboard accessible and adds no JavaScript or Nuxt UI theme (#314, #319).
10
+ - **Answers are plain text** (no Markdown/links), so the same strings work in the HTML, the JSON-LD and `/llms.txt`.
11
+ - Google shows FAQ rich results only for authoritative sites since 2023; the point is AI answers and on-page clarity.
12
+
13
+ ## Implementation
14
+
15
+ - `buildFaqPageSchema` in `app/utils/schema.ts`; `Home/Faq.vue` emits it via `useHead` (key `jsonld-faq`).
16
+ - `/llms.txt` gets a "Häufige Fragen" section after "Bestellen" (`queryCollection(event, "home").select("faq")`).
17
+ - Demo FAQ in `content/index.yml` with the facts from `zahlung-und-versand.md`. Note: the delivery info card in the same file says "darunter 1 € Liefergebühr", the payment page and the FAQ say 2 €.
18
+
19
+ ## Verification
20
+
21
+ Production build against the demo backend: home HTML has 7 `<details>` with all answers and a `FAQPage` node with 7 questions; `/llms.txt` lists them. Screenshots desktop light and mobile dark (via `nuxt-color-mode`, the demo's preference is light): consistent with the other sections, no hydration errors. All unit + nuxt tests (incl. new `HomeFaq.test.ts`), typecheck, ESLint green.
@@ -0,0 +1,22 @@
1
+ # Issue #411: quick view configuration in the URL, share button
2
+
3
+ As of 2026-10-05, branch `feature/411-quick-view-share`.
4
+
5
+ ## Decisions (agreed with Lirim)
6
+
7
+ - Readable parameters next to `produkt`: `ohne` = deselected main ingredients by name, `extras` = selected extras by product number, comma-separated. Unknown entries are ignored. IDs were rejected (long, unreadable links).
8
+ - Live: every change writes the URL with `router.replace` (no history entries); closing removes all three parameters.
9
+ - Share: Web Share API where available, otherwise clipboard + toast "Link kopiert". Icon button in the drawer header (`#actions` slot of `UDrawer`, before close).
10
+
11
+ ## Implementation
12
+
13
+ - `app/utils/productUrl.ts`: parameter names, `parseListParam`, `withQuickViewConfiguration(query, configuration | undefined)` (replaces the three parameters, keeps filters).
14
+ - `useProductQuickView`: a variant switch changes `produkt` to a number that may not be in the list. Without care the drawer would swap its product (and re-mount `ProductDetail`, losing the selection) or load the variant. Numbers the drawer wrote itself are kept in `useState("quick-view-switched-numbers")`; for them the opened product stays. Reset when another product opens or the drawer closes.
15
+ - `useQuickViewConfiguration`: `initial` (parsed from the route) and `update()`; `QuickView.vue` passes `initial` to `ProductDetail`, which hands it to `DeselectIngredient`/`CrossSelling` (read once at setup, emitted immediately so the cart payload and the price include them), and emits `configuration-changed` on ingredient, extras and variant changes.
16
+ - Cross-selling route and `AssociationItemProduct` carry `productNumber`.
17
+ - The header number follows the selected variant (was the opened product's number; visible since variant links, #289).
18
+ - `useShareLink`: `canShare` is set in `onMounted`, so SSR and hydration render the same icon.
19
+
20
+ ## Verification
21
+
22
+ Production build against the demo, Playwright: `?produkt=LF-21-gro%C3%9F&ohne=K%C3%A4se&extras=EXTRA-900,EXTRA-903` opens with Käse deselected, two extras checked, 12,00 € (10 + 2); toggling Tomatensoße appends it to `ohne`; switching to "Normal" sets `produkt=LF-21-normal`, the drawer stays open and keeps the selection; share copies the live URL and shows the toast (headless Chromium has no `navigator.share`); closing removes the parameters without a history entry, back goes to the previous page; no console errors, mobile and desktop. All unit + nuxt tests (new: helpers, initial selection, `useShareLink`), typecheck, ESLint green.
package/nuxt.config.ts CHANGED
@@ -57,6 +57,12 @@ export default defineNuxtConfig({
57
57
  },
58
58
  apiClientConfig: {},
59
59
  geoapifyApiKey: "",
60
+ // AI crawlers named in robots.txt (#403, server/plugins/ai-crawlers.ts):
61
+ // search = AI search and assistant fetches, training = model training.
62
+ aiCrawlers: {
63
+ search: true,
64
+ training: true,
65
+ },
60
66
  public: {
61
67
  shopBite: {
62
68
  cacheTtl: {
@@ -105,6 +111,15 @@ export default defineNuxtConfig({
105
111
  googleBusinessProfileUrl: "",
106
112
  // Restaurant schema only, e.g. "€€" (#272).
107
113
  priceRange: "",
114
+ // Restaurant schema only (#401): comma-separated delivery areas
115
+ // ("63179 Obertshausen, 63165 Lämmerspiel"), coordinates and
116
+ // "true"/"false" or a text for table reservations.
117
+ deliveryAreas: "",
118
+ geo: {
119
+ latitude: "",
120
+ longitude: "",
121
+ },
122
+ acceptsReservations: "",
108
123
  },
109
124
  storeUrl: "",
110
125
  // Matomo config, runtime-overridable via NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_*
@@ -121,6 +136,11 @@ export default defineNuxtConfig({
121
136
  },
122
137
 
123
138
  routeRules: {
139
+ // Rebuilt at most hourly: hours, closing days and the menu change rarely
140
+ // (#402).
141
+ "/llms.txt": {
142
+ swr: 3600,
143
+ },
124
144
  "/merkliste": {
125
145
  ssr: false,
126
146
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -17,7 +17,10 @@ const BASE_CRITERIA = {
17
17
  "cover",
18
18
  // "Ausverkauft" on the card (#325).
19
19
  "available",
20
+ // Product deep link (#289); the request sends `sw-include-seo-urls`.
21
+ "seoUrls",
20
22
  ],
23
+ seo_url: ["seoPathInfo", "isCanonical"],
21
24
  property: ["id", "name", "translated", "displayType", "options"],
22
25
  property_group_option: [
23
26
  "id",
@@ -6,7 +6,8 @@ const criteria = {
6
6
  includes: {
7
7
  cross_selling_element: ["crossSelling", "products"],
8
8
  cross_selling: ["name"],
9
- product: ["id", "name", "calculatedPrice", "translated"],
9
+ // productNumber: extras in the quick view URL (#411)
10
+ product: ["id", "productNumber", "name", "calculatedPrice", "translated"],
10
11
  calculated_price: ["unitPrice"],
11
12
  },
12
13
  };
@@ -0,0 +1,27 @@
1
+ import { buildAiCrawlerGroups } from "../utils/aiCrawlers";
2
+
3
+ /**
4
+ * Names the AI crawlers in robots.txt (#403): AI search bots are allowed by
5
+ * default, training bots follow `runtimeConfig.aiCrawlers.training`
6
+ * (NUXT_AI_CRAWLERS_TRAINING=false blocks them). Only runs for indexable
7
+ * sites; a non-indexable site (demo) keeps its single `Disallow: /`.
8
+ */
9
+ export default defineNitroPlugin((nitroApp) => {
10
+ nitroApp.hooks.hook("robots:config", (ctx) => {
11
+ const { aiCrawlers } = useRuntimeConfig(ctx.event);
12
+ const wildcard = ctx.groups.find((group) =>
13
+ [group.userAgent ?? "*"].flat().includes("*"),
14
+ );
15
+ const disallow = [wildcard?.disallow ?? []].flat();
16
+
17
+ ctx.groups.push(
18
+ ...buildAiCrawlerGroups(
19
+ {
20
+ search: aiCrawlers.search !== false,
21
+ training: aiCrawlers.training !== false,
22
+ },
23
+ disallow,
24
+ ),
25
+ );
26
+ });
27
+ });
@@ -0,0 +1,213 @@
1
+ import { queryCollection } from "@nuxt/content/server";
2
+ import type { components } from "~~/api-types/storeApiTypes";
3
+ import { getDiets, getMainIngredients } from "../../app/utils/product";
4
+ import { productDeepLink } from "../../app/utils/productUrl";
5
+ import { splitList, toAbsoluteUrl } from "../../app/utils/seo";
6
+ import { buildLlmsTxt, type LlmsMenuSection } from "../utils/llmsTxt";
7
+
8
+ type Schemas = components["schemas"];
9
+
10
+ // Store API maximum per request.
11
+ const PRODUCT_PAGE_SIZE = 100;
12
+ // A menu has a few hundred products at most (La Fattoria: 390 incl. extras).
13
+ const MAX_PRODUCT_PAGES = 10;
14
+
15
+ const NAVIGATION_CRITERIA = {
16
+ depth: 10,
17
+ buildTree: true,
18
+ includes: {
19
+ category: ["id", "name", "translated", "seoUrl", "type", "children"],
20
+ },
21
+ };
22
+
23
+ const PRODUCT_CRITERIA = {
24
+ limit: PRODUCT_PAGE_SIZE,
25
+ // Main products only; variants are summed up as "ab <cheapest price>".
26
+ filter: [{ type: "equals", field: "parentId", value: null }],
27
+ associations: { properties: { associations: { group: {} } } },
28
+ includes: {
29
+ product: [
30
+ "id",
31
+ "name",
32
+ "translated",
33
+ "categoryIds",
34
+ "childCount",
35
+ "calculatedPrice",
36
+ "calculatedCheapestPrice",
37
+ "sortedProperties",
38
+ "productNumber",
39
+ "seoUrls",
40
+ ],
41
+ seo_url: ["seoPathInfo", "isCanonical"],
42
+ calculated_price: ["unitPrice"],
43
+ calculated_cheapest_price: ["unitPrice"],
44
+ property_group: ["name", "translated", "options"],
45
+ property_group_option: ["name", "translated"],
46
+ },
47
+ };
48
+
49
+ /**
50
+ * `/llms.txt` (#402): the shop, its hours, ordering and the menu as Markdown
51
+ * for language models. Every source is optional; a failing request leaves
52
+ * its section out instead of failing the file.
53
+ */
54
+ export default defineEventHandler(async (event) => {
55
+ const { shopware, shopBite, site } = useRuntimeConfig(event).public;
56
+ const siteUrl = getSiteConfig(event).url;
57
+ const headers = { "sw-access-key": shopware.accessToken };
58
+ const menuRootId = shopBite.menuCategoryId || "main-navigation";
59
+
60
+ const storeApi = <T>(path: string, body?: Record<string, unknown>) =>
61
+ $fetch<T>(`${shopware.endpoint}${path}`, {
62
+ method: body ? "POST" : "GET",
63
+ headers: { ...headers, "sw-include-seo-urls": "true" },
64
+ body,
65
+ });
66
+
67
+ const [navigation, products, hours, holidays, config, context, pages, home] =
68
+ await Promise.allSettled([
69
+ storeApi<Schemas["Category"][]>(
70
+ `/navigation/${menuRootId}/${menuRootId}`,
71
+ NAVIGATION_CRITERIA,
72
+ ),
73
+ loadProducts((page) =>
74
+ storeApiPost<{ elements?: Schemas["Product"][] }>(
75
+ "/product",
76
+ { ...PRODUCT_CRITERIA, page },
77
+ { headers: { "sw-include-seo-urls": "true" } },
78
+ ),
79
+ ),
80
+ storeApi<{ businessHours?: Schemas["ShopbiteBusinessHour"][] }>(
81
+ "/shopbite/business-hour",
82
+ ),
83
+ storeApi<{ holidays?: { start?: string; end?: string }[] }>(
84
+ "/shopbite/holiday",
85
+ ),
86
+ storeApi<{ isCheckoutEnabled?: boolean; deliveryTime?: number }>(
87
+ "/shopbite/config",
88
+ ),
89
+ storeApi<Schemas["SalesChannelContext"]>("/context"),
90
+ queryCollection(event, "landingpages")
91
+ .select("path", "title", "description")
92
+ .all(),
93
+ queryCollection(event, "home").select("faq").first(),
94
+ ]);
95
+
96
+ const value = <T>(result: PromiseSettledResult<T>) =>
97
+ result.status === "fulfilled" ? result.value : undefined;
98
+
99
+ const productsByCategory = groupByCategory(value(products) ?? []);
100
+ const toSection = (category: Schemas["Category"]): LlmsMenuSection => ({
101
+ name: category.translated?.name ?? category.name,
102
+ url: category.seoUrl ? toAbsoluteUrl(siteUrl, category.seoUrl) : undefined,
103
+ items: (productsByCategory.get(category.id) ?? []).map((product) => {
104
+ const deepLink = productDeepLink(product, category.seoUrl);
105
+ return {
106
+ ...toMenuItem(product),
107
+ url: deepLink ? toAbsoluteUrl(siteUrl, deepLink) : undefined,
108
+ };
109
+ }),
110
+ sections: (category.children ?? [])
111
+ .filter((child) => child.type === "page")
112
+ .map(toSection),
113
+ });
114
+
115
+ const body = buildLlmsTxt({
116
+ name: site.name,
117
+ description: site.description,
118
+ url: siteUrl,
119
+ cuisine: site.cuisine,
120
+ address: {
121
+ street: site.address.street,
122
+ postalCode: site.address.postalCode
123
+ ? String(site.address.postalCode)
124
+ : undefined,
125
+ city: site.address.city,
126
+ },
127
+ telephone: site.telephone,
128
+ googleBusinessProfileUrl: site.googleBusinessProfileUrl,
129
+ deliveryAreas: splitList(site.deliveryAreas),
130
+ businessHours: value(hours)?.businessHours,
131
+ holidays: value(holidays)?.holidays,
132
+ isCheckoutEnabled: value(config)?.isCheckoutEnabled,
133
+ deliveryTime: value(config)?.deliveryTime,
134
+ menuUrl: toAbsoluteUrl(siteUrl, "/speisekarte"),
135
+ menu: (value(navigation) ?? [])
136
+ .filter((category) => category.type === "page")
137
+ .map(toSection),
138
+ pages: (value(pages) ?? [])
139
+ // Pages the shop keeps out of robots.txt (legal pages) stay out here.
140
+ .filter(
141
+ (page) =>
142
+ getPathRobotConfig(event, {
143
+ path: page.path,
144
+ skipSiteIndexable: true,
145
+ }).indexable,
146
+ )
147
+ .map((page) => ({
148
+ title: page.title,
149
+ url: toAbsoluteUrl(siteUrl, page.path),
150
+ description: page.description,
151
+ })),
152
+ faq: value(home)?.faq?.items,
153
+ currency: value(context)?.currency?.isoCode,
154
+ now: new Date(),
155
+ });
156
+
157
+ setResponseHeader(event, "Content-Type", "text/markdown; charset=utf-8");
158
+ return body;
159
+ });
160
+
161
+ async function loadProducts(
162
+ loadPage: (page: number) => Promise<{ elements?: Schemas["Product"][] }>,
163
+ ) {
164
+ const products: Schemas["Product"][] = [];
165
+ for (let page = 1; page <= MAX_PRODUCT_PAGES; page++) {
166
+ const elements = (await loadPage(page)).elements ?? [];
167
+ products.push(...elements);
168
+ if (elements.length < PRODUCT_PAGE_SIZE) break;
169
+ }
170
+ return products;
171
+ }
172
+
173
+ /** Products by the categories they are assigned to directly. */
174
+ function groupByCategory(products: Schemas["Product"][]) {
175
+ const byCategory = new Map<string, Schemas["Product"][]>();
176
+ for (const product of products) {
177
+ for (const categoryId of product.categoryIds ?? []) {
178
+ byCategory.set(categoryId, [
179
+ ...(byCategory.get(categoryId) ?? []),
180
+ product,
181
+ ]);
182
+ }
183
+ }
184
+ // Alphabetical, numbers in natural order ("Pizza 9" before "Pizza 10").
185
+ for (const items of byCategory.values()) {
186
+ items.sort((a, b) =>
187
+ (a.translated?.name ?? a.name).localeCompare(
188
+ b.translated?.name ?? b.name,
189
+ "de",
190
+ { numeric: true },
191
+ ),
192
+ );
193
+ }
194
+ return byCategory;
195
+ }
196
+
197
+ function toMenuItem(product: Schemas["Product"]) {
198
+ const properties = product.sortedProperties as
199
+ Schemas["PropertyGroup"][] | undefined;
200
+ const hasVariants = (product.childCount ?? 0) > 0;
201
+ return {
202
+ name: product.translated?.name ?? product.name,
203
+ price: hasVariants
204
+ ? (product.calculatedCheapestPrice?.unitPrice ??
205
+ product.calculatedPrice?.unitPrice)
206
+ : product.calculatedPrice?.unitPrice,
207
+ fromPrice: hasVariants,
208
+ ingredients: getMainIngredients(properties).map(
209
+ (option) => option.translated?.name ?? option.name,
210
+ ),
211
+ diets: getDiets(properties),
212
+ };
213
+ }
@@ -0,0 +1,79 @@
1
+ // robots.txt groups for AI crawlers (#403). Pure, so it is unit-testable;
2
+ // `server/plugins/ai-crawlers.ts` adds the groups at runtime.
3
+ //
4
+ // User agents as documented by the operators (checked 2026-10):
5
+ // OpenAI https://platform.openai.com/docs/bots, Anthropic
6
+ // https://support.claude.com/en/articles/8896518, Perplexity
7
+ // https://docs.perplexity.ai/guides/bots, Google
8
+ // https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers,
9
+ // Apple https://support.apple.com/en-us/119829, Common Crawl
10
+ // https://commoncrawl.org/ccbot, Meta
11
+ // https://developers.facebook.com/docs/sharing/webmasters/web-crawlers,
12
+ // Mistral https://docs.mistral.ai/robots.
13
+
14
+ /** Fetch pages to answer a user's question and link to the source. */
15
+ export const AI_SEARCH_USER_AGENTS = [
16
+ "OAI-SearchBot",
17
+ "ChatGPT-User",
18
+ "Claude-SearchBot",
19
+ "Claude-User",
20
+ "PerplexityBot",
21
+ "Perplexity-User",
22
+ "MistralAI-User",
23
+ ];
24
+
25
+ /**
26
+ * Collect content to train models. Google-Extended and Applebot-Extended are
27
+ * tokens only: Googlebot/Applebot crawl, the token decides about AI use.
28
+ */
29
+ export const AI_TRAINING_USER_AGENTS = [
30
+ "GPTBot",
31
+ "ClaudeBot",
32
+ "Google-Extended",
33
+ "Applebot-Extended",
34
+ "CCBot",
35
+ "meta-externalagent",
36
+ ];
37
+
38
+ export type AiCrawlerPolicy = {
39
+ /** Allow AI search and assistant fetches (default true). */
40
+ search: boolean;
41
+ /** Allow crawling for model training (default true). */
42
+ training: boolean;
43
+ };
44
+
45
+ type RobotsGroup = {
46
+ userAgent: string[];
47
+ allow: string[];
48
+ disallow: string[];
49
+ comment: string[];
50
+ };
51
+
52
+ /**
53
+ * One group per kind. A crawler that matches a named group ignores the `*`
54
+ * group, so an allowed group repeats its disallow rules.
55
+ */
56
+ export function buildAiCrawlerGroups(
57
+ policy: AiCrawlerPolicy,
58
+ disallow: string[],
59
+ ): RobotsGroup[] {
60
+ const group = (
61
+ comment: string,
62
+ userAgent: string[],
63
+ allowed: boolean,
64
+ ): RobotsGroup => ({
65
+ comment: [comment],
66
+ userAgent,
67
+ allow: allowed ? ["/"] : [],
68
+ disallow: allowed ? disallow.filter((path) => path && path !== "/") : ["/"],
69
+ });
70
+
71
+ return [
72
+ group(
73
+ "AI search and assistants: answer questions with a link to this shop",
74
+ AI_SEARCH_USER_AGENTS,
75
+ policy.search,
76
+ ),
77
+ group("AI model training", AI_TRAINING_USER_AGENTS, policy.training),
78
+ ];
79
+ }