diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..172351b
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,7 @@
+Copyright 2023-present, Weaverse JSC.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index ce3b611..8406755 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,29 @@
-# Pilot 👨🏻✈️ - Weaverse's Hydrogen-driven Shopify Theme
+
Pilot - Shopify Hydrogen Theme
-Pilot is an innovative Shopify theme, powered by Hydrogen, Remix, and Weaverse, designed to create lightning-fast storefronts with exceptional performance. This theme combines a collection of powerful tools and features to streamline your Shopify development experience.
+
+
+![Weaverse + Hydrogen + Shopify](https://cdn.shopify.com/s/files/1/0693/8201/3220/files/Logos.png?v=1695811776)
+
+📚 [Read the docs](https://weaverse.io/docs) | 🗣 [Join our community on Slack](https://join.slack.com/t/weaversecommunity/shared_invite/zt-235bv7d80-velzJU8CpZIHWdrzFwAdXg) | 🐞 [Report a bug](https://github.com/weaverse/pilot/issues)
+
+
+
+_Pilot is an innovative Shopify theme, powered by Hydrogen, Remix, and Weaverse, designed to create lightning-fast storefronts with exceptional performance. This theme combines a collection of powerful tools and features to streamline your Shopify development experience._
+
+### Demo
+
+- [Live store](https://pilot.weaverse.dev)
+- Try customizing Pilot on [Weaverse Playground](https://playground.weaverse.io)
+ ![demo](https://cdn.shopify.com/s/files/1/0693/8201/3220/files/Home.png?v=1695816170)
### What's included
@@ -14,21 +37,251 @@ Pilot is an innovative Shopify theme, powered by Hydrogen, Remix, and Weaverse,
- TypeScript and JavaScript flavors
- Tailwind CSS (via PostCSS)
- Full-featured setup of components and routes
-- Easy to edit and customize with **Weaverse Hydrogen Editor**
+- Fully customizable inside [Weaverse](https://weaverse.io)
### Getting started
Follow these steps to get started with Pilot and begin crafting your Hydrogen-driven storefront:
-1. Install [Weaverse Shopify App](https://apps.shopify.com/weaverse) from Shopify App Store.
+1. Install [Weaverse Hydrogen Customizer](https://apps.shopify.com/weaverse) from Shopify App Store.
2. Create new Hydrogen storefront inside Weaverse.
-3. Clone the repository that Weaverse has created for you.
-4. Set environment variables in `.env` file then start the development server with `npm i && npm run dev`.
-5. Open the Weaverse editor to start customizing and tailoring your storefront according to your preferences.
+3. Initialize the project and start a local dev server with our CLI tool as instructed in the Weaverse editor.
+ ![Init Weaverse Storefront](https://cdn.shopify.com/s/files/1/0693/8201/3220/files/init-project_4882deaa-c661-47cc-a7bf-38b2704e6a0b.png?v=1695816089)
+4. Open the Weaverse editor to start customizing and tailoring your storefront according to your preferences.
+
+### Features overview
+
+#### Fetching page data inside route's loader
+
+Fetching page data inside route's loader is a common pattern in Hydrogen. Weaverse provides a convenient way to do that by using `context.weaverse.loadPage` function. It accepts `RouteLoaderArgs` as an argument and returns a promise with the page data.
+
+```ts:routes/($locale)/_index.tsx
+import {defer} from '@shopify/remix-oxygen';
+import {type RouteLoaderArgs} from '@weaverse/hydrogen';
+
+export async function loader(args: RouteLoaderArgs) {
+ let {params, context} = args;
+
+ return defer({
+ weaverseData: await context.weaverse.loadPage(args),
+ // Other data...
+ });
+}
+```
+
+`weaverse` is an `WeaverseClient` instance that has been injected into the app context by Weaverse. It provides a set of methods to interact with the Weaverse API.
+
+```ts:server.ts
+let handleRequest = createRequestHandler({
+ build: remixBuild,
+ mode: process.env.NODE_ENV,
+ getLoadContext: () => ({
+ // App context props
+ weaverse: createWeaverseClient({
+ storefront,
+ request,
+ env,
+ cache,
+ waitUntil,
+ }),
+ }),
+});
+```
+
+#### Rendering page content
+
+Weaverse pages is rendered using `` component.
+
+```tsx:app/weaverse/index.tsx
+import {WeaverseHydrogenRoot} from '@weaverse/hydrogen';
+import {GenericError} from '~/components/GenericError';
+import {components} from './components';
+
+export function WeaverseContent() {
+ return (
+
+ );
+}
+
+```
+
+And in your route:
+
+```tsx:routes/($locale)/_index.tsx
+export default function Homepage() {
+ return ;
+}
+```
+
+Dead simple, right?
+
+#### Global theme settings
+
+Weaverse global theme settings is loaded in the `root`'s loader with `context.weaverse.loadThemeSettings` function.
+
+```tsx:root.tsx
+export async function loader({request, context}: RouteLoaderArgs) {
+ return defer({
+ // App data...
+ weaverseTheme: await context.weaverse.loadThemeSettings(),
+ });
+}
+```
+
+And then you can use it in your components with `useThemeSettings` hook.
+
+```tsx:app/weaverse/components/Logo.tsx
+import {useThemeSettings} from '@weaverse/hydrogen';
+
+function Logo() {
+ let {logo} = useThemeSettings();
+
+ return (
+
+
+
+ );
+}
+```
+
+The `App` component is wrapped with `withWeaverse` HoC in order to SSR the theme settings.
+
+```tsx:root.text
+import {withWeaverse} from '@weaverse/hydrogen';
+
+function App() {
+ return (
+
+ // App markup
+
+ );
+}
+
+export default withWeaverse(App);
+```
+
+#### Create a section
+
+To create a section, you need to create a new file in `app/weaverse/sections` directory and register it in `app/weaverse/sections/index.ts` file.
+
+```tsx:app/weaverse/sections/Video.tsx
+import type {
+ HydrogenComponentProps,
+ HydrogenComponentSchema,
+} from '@weaverse/hydrogen';
+import {forwardRef} from 'react';
+
+interface VideoProps extends HydrogenComponentProps {
+ heading: string;
+ description: string;
+ videoUrl: string;
+}
+
+let Video = forwardRef((props, ref) => {
+ let {heading, description, videoUrl, ...rest} = props;
+ return (
+
+
+
+ {heading}
+
+
+ {description}
+
+
+
+
+ );
+});
+
+export default Video;
+```
+
+Export a `schema` object from the file to define the component's schema with default data and settings to be used in the Weaverse editor.
+
+```tsx:app/weaverse/sections/Video.tsx
+export let schema: HydrogenComponentSchema = {
+ type: 'video',
+ title: 'Video',
+ toolbar: ['general-settings', ['duplicate', 'delete']],
+ inspector: [
+ {
+ group: 'Video',
+ inputs: [
+ {
+ type: 'text',
+ name: 'heading',
+ label: 'Heading',
+ defaultValue: 'Learn More About Our Products',
+ placeholder: 'Learn More About Our Products',
+ },
+ {
+ type: 'textarea',
+ name: 'description',
+ label: 'Description',
+ defaultValue: `Watch these short videos to see our products in action. Learn how to use them and what makes them special. See demos of our products being used in real-life situations. The videos provide extra details and showcase the full capabilities of what we offer. If you're interested in learning more before you buy, be sure to check out these informative product videos.`,
+ placeholder: 'Video description',
+ },
+ {
+ type: 'text',
+ name: 'videoUrl',
+ label: 'Video URL',
+ defaultValue: 'https://www.youtube.com/embed/-akQyQN8rYM',
+ placeholder: 'https://www.youtube.com/embed/-akQyQN8rYM',
+ },
+ ],
+ },
+ ],
+};
+```
+
+What if your component needs to fetch data from Shopify API or any third-party API?
+
+Weaverse provide a powerful `loader` function to fetch data from any API, and it's run on the server-side 🤯😎.
+
+Just export a `loader` function from your component:
+
+```tsx:app/weaverse/sections/Video.tsx
+import type {ComponentLoaderArgs} from '@weaverse/hydrogen';
+
+export let loader = async ({context, itemData}: ComponentLoaderArgs) => {
+ let {data} = await context.storefront.query(
+ HOMEPAGE_SEO_QUERY,
+ {
+ variables: {handle: itemData.data.collectionHandle || 'frontpage'},
+ },
+ );
+ return data;
+};
+```
+
+And then you can use the data in your component with `Component.props.loaderData` 🤗
+
+#### Customizing the theme inside Weaverse Editor
+
+Weaverse provides a convenient way to customize your theme inside the Weaverse editor. You can add new sections, customize existing ones, and change the theme settings.
+
+![Weaverse Editor](https://cdn.shopify.com/s/files/1/0693/8201/3220/files/Live_demo_-_Weaverse_Hydrogen_2023-09-27_18-58-23.jpg?v=1695815948)
### References
+- [Weaverse docs](https://weaverse.io/docs)
- [Hydrogen docs](https://shopify.dev/custom-storefronts/hydrogen)
-- [Remix.run](https://remix.run/docs/en/v1)
+- [Remix.run](https://remix.run/)
+
+### License
+
+This project is provided under the [MIT License](LICENSE).
+
+---
Let Pilot empower your Shopify store with top-notch performance and unmatched customization possibilities! 🚀
diff --git a/app/components/Icon.tsx b/app/components/Icon.tsx
index fa5bdf0..be9114e 100644
--- a/app/components/Icon.tsx
+++ b/app/components/Icon.tsx
@@ -270,3 +270,46 @@ export function IconFilters(props: IconProps) {
);
}
+
+export function IconPinterest(props: IconProps) {
+ return (
+
+
+
+
+ );
+}
+export function IconFacebook(props: IconProps) {
+ return (
+
+
+
+
+
+ );
+}
diff --git a/app/data/queries.ts b/app/data/queries.ts
index 4d47aa4..fe994fa 100644
--- a/app/data/queries.ts
+++ b/app/data/queries.ts
@@ -379,6 +379,7 @@ export let ARTICLE_QUERY = `#graphql
title
contentHtml
publishedAt
+ tags
author: authorV2 {
name
}
@@ -394,7 +395,31 @@ export let ARTICLE_QUERY = `#graphql
title
}
}
+ articles (first: 20) {
+ nodes {
+ ...Article
+ }
+ }
+ }
+ }
+ fragment Article on Article {
+ author: authorV2 {
+ name
}
+ contentHtml
+ excerpt
+ excerptHtml
+ handle
+ id
+ image {
+ id
+ altText
+ url
+ width
+ height
+ }
+ publishedAt
+ title
}
`;
diff --git a/app/lib/session.server.ts b/app/lib/session.server.ts
index 4af86a0..7f0550c 100644
--- a/app/lib/session.server.ts
+++ b/app/lib/session.server.ts
@@ -10,12 +10,12 @@ import {
* swap out the cookie-based implementation with something else!
*/
export class HydrogenSession {
- constructor(
- private sessionStorage: SessionStorage,
- private session: Session,
- ) {
- this.session = session;
- this.sessionStorage = sessionStorage;
+ #sessionStorage;
+ #session;
+
+ constructor(sessionStorage: SessionStorage, session: Session) {
+ this.#sessionStorage = sessionStorage;
+ this.#session = session;
}
static async init(request: Request, secrets: string[]) {
@@ -34,31 +34,31 @@ export class HydrogenSession {
return new this(storage, session);
}
- has(key: string) {
- return this.session.has(key);
+ get has() {
+ return this.#session.has;
}
- get(key: string) {
- return this.session.get(key);
+ get get() {
+ return this.#session.get;
}
- destroy() {
- return this.sessionStorage.destroySession(this.session);
+ get flash() {
+ return this.#session.flash;
}
- flash(key: string, value: any) {
- this.session.flash(key, value);
+ get unset() {
+ return this.#session.unset;
}
- unset(key: string) {
- this.session.unset(key);
+ get set() {
+ return this.#session.set;
}
- set(key: string, value: any) {
- this.session.set(key, value);
+ destroy() {
+ return this.#sessionStorage.destroySession(this.#session);
}
commit() {
- return this.sessionStorage.commitSession(this.session);
+ return this.#sessionStorage.commitSession(this.#session);
}
}
diff --git a/app/lib/utils.ts b/app/lib/utils.ts
index 98e6711..4175218 100644
--- a/app/lib/utils.ts
+++ b/app/lib/utils.ts
@@ -1,5 +1,4 @@
import {useLocation, useMatches} from '@remix-run/react';
-import {parse as parseCookie} from 'worktop/cookie';
import type {MoneyV2} from '@shopify/hydrogen/storefront-api-types';
import typographicBase from 'typographic-base';
@@ -332,13 +331,3 @@ export function isLocalPath(url: string) {
return false;
}
-
-/**
- * Shopify's 'Online Store' stores cart IDs in a 'cart' cookie.
- * By doing the same, merchants can switch from the Online Store to Hydrogen
- * without customers losing carts.
- */
-export function getCartId(request: Request) {
- const cookies = parseCookie(request.headers.get('Cookie') || '');
- return cookies.cart ? `gid://shopify/Cart/${cookies.cart}` : undefined;
-}
diff --git a/app/routes/($locale).account.tsx b/app/routes/($locale).account.tsx
index cc01d3c..9afff57 100644
--- a/app/routes/($locale).account.tsx
+++ b/app/routes/($locale).account.tsx
@@ -51,7 +51,7 @@ export async function loader({request, context, params}: LoaderArgs) {
const {pathname} = new URL(request.url);
const locale = params.locale;
const customerAccessToken = await context.session.get('customerAccessToken');
- const isAuthenticated = Boolean(customerAccessToken);
+ const isAuthenticated = !!customerAccessToken;
const loginPath = locale ? `/${locale}/account/login` : '/account/login';
const isAccountPage = /^\/account\/?$/.test(pathname);
diff --git a/app/routes/($locale).blogs.$blogHandle.$articleHandle.tsx b/app/routes/($locale).blogs.$blogHandle.$articleHandle.tsx
index c8139da..b99e2f4 100644
--- a/app/routes/($locale).blogs.$blogHandle.$articleHandle.tsx
+++ b/app/routes/($locale).blogs.$blogHandle.$articleHandle.tsx
@@ -37,6 +37,8 @@ export async function loader(args: RouteLoaderArgs) {
}
const article = blog.articleByHandle;
+ const relatedArticles = blog.articles.nodes
+ .filter(art => art?.handle !== params?.articleHandle);
const formattedDate = new Intl.DateTimeFormat(`${language}-${country}`, {
year: 'numeric',
@@ -48,6 +50,10 @@ export async function loader(args: RouteLoaderArgs) {
return json({
article,
+ blog: {
+ handle: params.blogHandle,
+ },
+ relatedArticles,
formattedDate,
seo,
weaverseData: await context.weaverse.loadPage(args),
diff --git a/app/sections/blog-post.tsx b/app/sections/blog-post.tsx
index bc2571b..e873740 100644
--- a/app/sections/blog-post.tsx
+++ b/app/sections/blog-post.tsx
@@ -1,13 +1,13 @@
-import {useLoaderData} from '@remix-run/react';
-import {Image} from '@shopify/hydrogen';
-import {Article} from '@shopify/hydrogen/storefront-api-types';
+import { useLoaderData } from '@remix-run/react';
+import { Image } from '@shopify/hydrogen';
+import { Article } from '@shopify/hydrogen/storefront-api-types';
import type {
HydrogenComponentProps,
HydrogenComponentSchema,
} from '@weaverse/hydrogen';
-import {forwardRef} from 'react';
+import { forwardRef } from 'react';
-import {PageHeader, Section} from '~/components';
+import { IconFacebook, IconPinterest, Section } from '~/components';
interface BlogPostProps extends HydrogenComponentProps {
paddingTop: number;
@@ -20,8 +20,7 @@ let BlogPost = forwardRef((props, ref) => {
article: Article;
formattedDate: string;
}>();
- let {title, image, contentHtml, author} = article;
-
+ let {title, image, contentHtml, author, tags} = article;
if (article) {
return (
@@ -31,24 +30,37 @@ let BlogPost = forwardRef((props, ref) => {
paddingBottom: `${paddingBottom}px`,
}}
>
-
-
- {formattedDate} · {author?.name}
-
-
-
+
{image && (
)}
-
+
+ {formattedDate}
+
{title}
+ by {author?.name}
+
+
+
+
+
+
+
+ Tags:
+ {tags.join(', ')}
+
+
+ Share:
+
+
+
+
+
+
diff --git a/app/sections/collection-filters/index.tsx b/app/sections/collection-filters/index.tsx
new file mode 100644
index 0000000..4404e17
--- /dev/null
+++ b/app/sections/collection-filters/index.tsx
@@ -0,0 +1,138 @@
+import {useLoaderData} from '@remix-run/react';
+import {Pagination} from '@shopify/hydrogen';
+import type {Filter} from '@shopify/hydrogen/storefront-api-types';
+import type {
+ HydrogenComponentProps,
+ HydrogenComponentSchema,
+} from '@weaverse/hydrogen';
+import {forwardRef} from 'react';
+import {useInView} from 'react-intersection-observer';
+import {CollectionDetailsQuery} from 'storefrontapi.generated';
+import {Button, PageHeader, Section, SortFilter, Text} from '~/components';
+import type {AppliedFilter} from '~/components/SortFilter';
+import {ProductsLoadedOnScroll} from './products-loaded-on-scroll';
+
+interface CollectionFiltersProps extends HydrogenComponentProps {
+ showCollectionDescription: boolean;
+ loadPrevText: string;
+ loadMoreText: string;
+}
+
+let CollectionFilters = forwardRef(
+ (props, sectionRef) => {
+ let {showCollectionDescription, loadPrevText, loadMoreText, ...rest} =
+ props;
+
+ let {ref, inView} = useInView();
+ let {collection, collections, appliedFilters} = useLoaderData<
+ CollectionDetailsQuery & {
+ collections: Array<{handle: string; title: string}>;
+ appliedFilters: AppliedFilter[];
+ }
+ >();
+
+ if (collection?.products && collections) {
+ return (
+
+
+ {showCollectionDescription && collection?.description && (
+