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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta title and description section to Settings panel #1621

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions apps/studio/src/lib/projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export class ProjectsManager {
base: null,
custom: null,
},
metaTitle: '',
metaDescription: '',
};

const updatedProjects = [...this._projects, newProject];
Expand Down
60 changes: 60 additions & 0 deletions apps/studio/src/routes/editor/SettingsModal/Domain/MetaSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useProjectsManager } from '@/components/Context';
import { Input } from '@onlook/ui/input';
import { observer } from 'mobx-react-lite';
import React from 'react';

const MetaSection = observer(() => {
const projectsManager = useProjectsManager();
const project = projectsManager.project;

const metaTitle = project?.metaTitle || '';
const metaDescription = project?.metaDescription || '';

return (
<div className="space-y-4">
<h2 className="text-lg">Meta Information</h2>
<div className="space-y-4">
<div className="flex justify-between items-center">
<div className="w-1/3">
<p className="text-regularPlus text-muted-foreground">Title</p>
<p className="text-small text-muted-foreground">
Page title for search engines
</p>
</div>
<Input
id="metaTitle"
value={metaTitle}
onChange={(e) =>
projectsManager.updatePartialProject({
metaTitle: e.target.value,
})
}
placeholder="Enter page title"
className="w-2/3 bg-background placeholder:text-muted-foreground"
/>
</div>
<div className="flex justify-between items-center">
<div className="w-1/3">
<p className="text-regularPlus text-muted-foreground">Description</p>
<p className="text-small text-muted-foreground">
Page description for search engines
</p>
</div>
<Input
id="metaDescription"
value={metaDescription}
onChange={(e) =>
projectsManager.updatePartialProject({
metaDescription: e.target.value,
})
}
placeholder="Enter page description"
className="w-2/3 bg-background placeholder:text-muted-foreground"
/>
</div>
</div>
</div>
);
});

export default MetaSection;
5 changes: 5 additions & 0 deletions apps/studio/src/routes/editor/SettingsModal/Domain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect } from 'react';
import BaseDomain from './Base';
import { CustomDomain } from './Custom';
import DangerZone from './DangerZone';
import MetaSection from './MetaSection';

export const DomainTab = observer(() => {
const userManager = useUserManager();
Expand All @@ -24,6 +25,10 @@ export const DomainTab = observer(() => {
<CustomDomain />
</div>
<Separator />
<div className="p-4">
<MetaSection />
</div>
<Separator />
<div className="p-4">
<DangerZone />
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/models/src/projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface Project {
base: DomainSettings | null;
custom: DomainSettings | null;
} | null;
metaTitle?: string;
metaDescription?: string;

// deprecated
// hosting?: HostingSettings | null;
Expand Down