Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft of Live Editing #40

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8f9e240
Draft of Live Editing
chenaski Oct 26, 2023
00a06a6
Add `view` param to url
chenaski Oct 26, 2023
5ab3608
Use `@sanity/overlays`
chenaski Nov 1, 2023
81d8460
Rollback
chenaski Nov 3, 2023
600ac57
Add `focus-reactive/sanity-overlay`
chenaski Nov 3, 2023
fa64d8a
Add `excludedPaths` to `patchDataWithStega`
chenaski Nov 3, 2023
65e2852
Rename `excludedPaths` to `enableVisualEditing`
chenaski Nov 3, 2023
3626e5f
Enable visual editing
chenaski Nov 3, 2023
c89700d
Remove `@sanity/overlays` from root
chenaski Nov 3, 2023
bd1e3be
Add `@sanity/overlays` to `@focus-reactive/sanity-overlay`
chenaski Nov 3, 2023
29b1a36
Add `pnpm-workspace.yaml`
chenaski Nov 3, 2023
40cf0d8
Update `pnpm-lock.yaml`
chenaski Nov 3, 2023
1c6829c
Enable visual editing inside Studio
chenaski Nov 13, 2023
40aedd8
Enable visual editing only in draft mode
chenaski Nov 13, 2023
2d6f86f
Fix bug with link when two panes opened
chenaski Nov 13, 2023
5f09ceb
Open split view inside studio
chenaski Nov 14, 2023
7eec25f
Switch to `es6`
chenaski Nov 14, 2023
66afd02
Fix ts error
chenaski Nov 14, 2023
580c7ce
Update test
chenaski Nov 14, 2023
3e66abd
Fix `excludedPaths`
chenaski Nov 14, 2023
0005576
Add cache to `enableVisualEditing`
chenaski Nov 16, 2023
33f01ec
Add some more buttons to overlay
chenaski Nov 24, 2023
8270a98
Always show overlays
chenaski Nov 24, 2023
95050f8
Add title to buttons with icons
chenaski Nov 24, 2023
55abcb4
Remove action from all buttons other than edit
chenaski Nov 24, 2023
2925c90
Add `inlineSvgInput` plugin
chenaski Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

Expand Down
6 changes: 6 additions & 0 deletions app/(frontend)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import './globals.css';

import { DM_Sans } from 'next/font/google';
import { VisualEditingOverlay } from '@focusreactive/sanity-overlay';
import { draftMode } from 'next/headers';

const dmSans = DM_Sans({ subsets: ['latin'] });

export default async function RootLayout({ children }: { children: React.ReactNode }) {
// const isDraftMode = draftMode().isEnabled;
const isDraftMode = true;

return (
<html lang="en">
<body className={dmSans.className}>{children}</body>
<VisualEditingOverlay isDraftMode={isDraftMode} />
</html>
);
}
14 changes: 11 additions & 3 deletions components/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import { Footer, Header } from '@focusreactive/cms-kit';
import { ContentBlocks } from '@/components/ContentBlocks';
import { SanityDocument } from 'sanity';
import { enableVisualEditing } from '@focusreactive/sanity-overlay';

export const Page = ({ page }: { page: SanityDocument }) => {
const start = performance.now();
const editablePage = enableVisualEditing({
data: page,
excludedPaths: [/.*footer\.socials\[\d+\]\.icon.*/, /.*\.(bgColor|sectionConfig)/],
});
console.log('enableVisualEditing', performance.now() - start);

return (
<>
<Header
{...(page?.header as any)}
{...(editablePage?.header as any)}
isFixed={false}
buttonsColor=""
linksColor="white"
heroBackgroundColor="default"
/>

<main>
<ContentBlocks blocks={page?.content as any} />;
<ContentBlocks blocks={editablePage?.content as any} />;
</main>

<Footer {...(page?.footer as any)} />
<Footer {...(editablePage?.footer as any)} />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ const iconsSet = {
const Item = ({ icon, link }: { icon: keyof typeof iconsSet; link: string }) => {
const Icon = iconsSet[icon];

if (!Icon) return null;

return (
<Link href={link || 'https://harcodedsocials.com'} target="_blank" aria-label={icon}>
{/* @ts-ignore */}
Expand Down
Loading