Skip to content

Commit

Permalink
Move store
Browse files Browse the repository at this point in the history
  • Loading branch information
RoelLeijser committed Nov 6, 2024
1 parent e4c555c commit cc75ad6
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 26 deletions.
6 changes: 0 additions & 6 deletions browser/create-template/templates/nextjs-site/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import path from 'path';
const nextConfig = {
// temporary workaround for using symlinked package with turbopack
outputFileTracingRoot: path.join(import.meta.dirname, '../../../'),
webpack: config => {
config.resolve.extensionAlias = {
'.js': ['.ts', '.tsx', '.js'],
};

return config;
},
experimental: {
turbo: {},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { website } from '@/ontologies/website';
import { CollectionBuilder, core } from '@tomic/lib';
import { store } from '@/app/store';
import { store } from '@/store';

export async function getAllBlogposts(): Promise<string[]> {
const collection = new CollectionBuilder(store)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CollectionBuilder, type Resource } from '@tomic/lib';
import { website } from '@/ontologies/website';
import { store } from '@/app/store';
import { store } from '@/store';

/**
* Queries the server for a resource with a href property that matches the given url pathname.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { env } from '@/env';
import { Website } from '@/ontologies/website';
import MenuItem from '@/views/MenuItem/MenuItem';
import styles from './Navbar.module.css';
import { store } from '@/app/store';
import { store } from '@/store';
import Link from 'next/link';

const Navbar = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { StoreContext } from '@tomic/react';
import { CurrentSubjectProvider } from '@/app/context/CurrentSubjectContext';
import { store } from '@/app/store';
import { store } from '@/store';
import { initOntologies } from '@/ontologies';

const ProviderWrapper = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import FaMagnifyingGlass from './Icons/magnifying-glass-solid.svg';
import Image from 'next/image';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { useEffect, useState } from 'react';
import { useThrottle } from '@/utils';
import { useThrottle } from '@/hooks';

const Searchbar = () => {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();

const [val, setVal] = useState(searchParams.get('search') ?? '');
const throttledValue = useThrottle(val, 200);
const [search, setSearch] = useState(searchParams.get('search') ?? '');
const throttledSearch = useThrottle(search, 200);

useEffect(() => {
if (throttledValue === '') {
if (throttledSearch === '') {
router.push(pathname);
} else {
router.push(`${pathname}?search=${throttledValue}`);
router.push(`${pathname}?search=${throttledSearch}`);
}
}, [throttledValue]);
}, [throttledSearch]);

return (
<div className={styles.searchBar}>
Expand All @@ -37,9 +37,9 @@ const Searchbar = () => {
<input
className={styles.input}
type='search'
value={val}
value={search}
onChange={e => {
setVal(e.target.value);
setSearch(e.target.value);
}}
aria-label='Search'
placeholder='Search blogposts...'
Expand Down
6 changes: 4 additions & 2 deletions browser/create-template/templates/nextjs-site/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

export const env = createEnv({
server: {},

// Client variables are exposed to the browser. They must be prefixed with NEXT_PUBLIC_.
client: {
NEXT_PUBLIC_ATOMIC_SERVER_URL: z.string().url(),
NEXT_PUBLIC_WEBSITE_RESOURCE: z.string().url(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import DefaultView from '../DefaultView';
import TextBlock from './TextBlock';
import { website } from '@/ontologies/website';
import ImageGalleryBlock from './ImageGalleryBlock';
import { store } from '@/app/store';
import { store } from '@/store';

const BlockView = async ({ subject }: { subject: string }) => {
const block = await store.getResource(subject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ListItemView from '../ListItem/ListItemView';
import { getAllBlogposts } from '@/atomic/getAllBlogposts';
import { Suspense } from 'react';
import Searchbar from '@/components/Searchbar';
import { store } from '@/app/store';
import { store } from '@/store';

const BlogIndexPageFullPage = async ({
resource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PageFullPage from './PageFullPage';
import BlogIndexPageFullPage from './BlogIndexPageFullPage';
import BlogpostFullPage from './BlogpostFullPage';
import DefaultFullPage from './DefaultFullPage';
import { store } from '@/app/store';
import { store } from '@/store';

const FullPageView = async ({
subject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { website } from '@/ontologies/website';
import BlogListItem from './BlogListItem';
import DefaultView from '@/views/DefaultView';
import { store } from '@/app/store';
import { store } from '@/store';

const ListItemView = async ({ subject }: { subject: string }) => {
const listItem = await store.getResource(subject);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MenuItem } from '@/ontologies/website';
import MenuItemLink from './MenuItemLink';
import styles from './MenuItem.module.css';
import { store } from '@/app/store';
import { store } from '@/store';
import { unknownSubject } from '@tomic/lib';

const MenuItem = async ({ subject }: { subject: string }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { website } from '@/ontologies/website';
import { unknownSubject, Resource } from '@tomic/lib';
import styles from './MenuItemLink.module.css';
import clsx from 'clsx';
import { store } from '@/app/store';
import { store } from '@/store';

const MenuItemLink = async ({
resource,
Expand Down

0 comments on commit cc75ad6

Please sign in to comment.