Skip to content

Commit

Permalink
feat(nuxt3-app): add 404 component (SWF-235)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanilowicz committed Jan 2, 2023
1 parent 745e66e commit b029167
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-peas-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vue-demo-store": minor
---

Add page not found component
15 changes: 15 additions & 0 deletions templates/vue-demo-store/components/errors/RoutingNotFound.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<section class="container mx-auto text-center my-20">
<h1 class="text-4xl font-bold mb-3">Page not found</h1>
<p class="text-sm mb-3">
We are sorry, the page you're looking for could not be found. It may no
longer exist or may have been moved.
</p>
<router-link
class="inline-flex justify-center items-center py-2 px-4 text-base font-medium text-center text-white bg-brand-primary rounded-lg hover:bg-gray-400"
to="/"
>
Back to homepage
</router-link>
</section>
</template>
4 changes: 4 additions & 0 deletions templates/vue-demo-store/pages/[...all].vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "@shopware-pwa/composables-next";
import { SeoUrl } from "@shopware-pwa/types";
const NOT_FOUND_COMPONENT = "errors/RoutingNotFound";
const { resolvePath } = useNavigationSearch();
const route = useRoute();
Expand All @@ -29,6 +30,9 @@ const { routeName, foreignKey } = useNavigationContext(
function render() {
const componentName = routeName.value;
if (!componentName)
return h("div", h(resolveComponent(pascalCase(NOT_FOUND_COMPONENT))));
const componentNameToResolve = pascalCase(componentName as string);
const cmsPageView = routeName && resolveComponent(componentNameToResolve);
if (cmsPageView) {
Expand Down

0 comments on commit b029167

Please sign in to comment.