Skip to content

Commit

Permalink
refactor: purge blog schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Oct 10, 2024
1 parent 96132fc commit 831e47f
Show file tree
Hide file tree
Showing 19 changed files with 5 additions and 654 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Variant’s webpages are based off of Sankitty — a Next.js and Sanity-powered
- **CMS-Driven Content Management:** Pages are dynamically constructed using content blocks defined in Sanity. This CMS-like approach enables content creators to manage all aspects of the site, from page content to menus and SEO, without touching the codebase.
- **Storybook Integration:** Sankitty includes Storybook for isolated component development and testing. This allows for the visual verification of UI components, ensuring design consistency and usability across the application.
- **Scoped Styling with CSS Modules:** CSS Modules are used for local scoping of styles, preventing naming conflicts and making it easier to maintain and scale the styling of components.
- **Universal Content Control:** Manage everything from a single location in Sanity—menus, SEO settings, logos, pages, blogs, and posts—offering a unified content management experience.
- **Universal Content Control:** Manage everything from a single location in Sanity—menus, SEO settings, logos and pages—offering a unified content management experience.
- **Custom Theming and Typography:** Global styles such as colors are managed in global.css, while typography is primarily controlled within Text.tsx, ensuring a consistent design language throughout the application.

## Shared Studio
Expand All @@ -46,7 +46,6 @@ In addition to the primary Sanity Studio (accessible at http://localhost:3000/st

### Features of Shared Studio

- Blog Posts: In the Shared Studio, you can create and manage Blog Posts. This content type allows for creating articles that can be displayed across different parts of the application.
- Customer Cases: Customer Cases is another content type available in the Shared Studio, enabling you to showcase client stories or testimonials.

Accessing Shared Studio
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/languageMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function negotiateClientLanguage(
* - If a page does not exist in the user's preferred language, the system will show the default language version instead of a 404 error.
*
* Limitations/Notes:
* - No special handling for nested paths (e.g., `/blogg` and `/blogg/post` are treated as distinct slugs `blogg` and `blogg/post`).
* - No special handling for nested paths (e.g., `/kunder` and `/kunder/nav` are treated as distinct slugs `kunder` and `kunder/nav`).
* - **False friend handling:**
* - For words spelled the same in different languages, but with different meanings (e.g., "gift" in Norwegian and English),
* the system prioritizes the user's preferred language and reroutes to the correct content based on translations.
Expand Down
41 changes: 0 additions & 41 deletions src/utils/api.ts

This file was deleted.

86 changes: 0 additions & 86 deletions src/utils/hooks/useFetchPosts.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/utils/seo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { toPlainText } from "@portabletext/toolkit";
import type { QueryParams } from "@sanity/client";
import { Metadata } from "next";
import { PortableTextBlock } from "sanity";

import { urlFor } from "studio/lib/image";
import { BrandAssets } from "studio/lib/interfaces/brandAssets";
Expand All @@ -21,13 +19,6 @@ type SeoData = {
keywords: string;
};

type PostSeoData = {
title: string;
description: PortableTextBlock[];
imageUrl: string;
keywords: string;
};

export const OPEN_GRAPH_IMAGE_DIMENSIONS = {
width: 1200,
height: 630,
Expand All @@ -46,30 +37,6 @@ export async function fetchSeoData(
}
}

export async function fetchPostSeoData(
query: string,
variables?: QueryParams | undefined,
): Promise<SeoData | null> {
try {
const { data } = await loadStudioQuery<PostSeoData>(query, variables);
if (data && data.description) {
const plainTextDescription = toPlainText(data.description);

return {
title: data.title,
description: plainTextDescription,
imageUrl: data.imageUrl,
keywords: data.keywords,
};
}

return null;
} catch (error) {
console.error("Error loading SEO data:", error);
return null;
}
}

export async function generateMetadataFromSeo(
seo: SeoData | null,
): Promise<Metadata> {
Expand Down
57 changes: 0 additions & 57 deletions studio/components/CategorySelect.tsx

This file was deleted.

5 changes: 1 addition & 4 deletions studio/components/ClearLinkFieldsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const ClearLinkFieldsButton = ({ path }: ClearLinkFieldsButtonProps) => {
const sectionKey = path[1]._key;
if (!sectionKey) return "";

if (path[2] === "posts" && isObjectWithKey(path[3])) {
const postKey = path[3]._key;
return `sections[_key=="${sectionKey}"].posts[_key=="${postKey}"].callToAction`;
} else if (path[2] === "clearFields") {
if (path[2] === "clearFields") {
return `sections[_key=="${sectionKey}"].${linkID}`;
} else {
return `sections[_key=="${sectionKey}"].callToAction`;
Expand Down
9 changes: 0 additions & 9 deletions studio/deskStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@ const specialPagesSection = (S: StructureBuilder) =>
S.list()
.title("Special Pages")
.items([
// S.listItem()
// .title("Blog Overview & Settings")
// .icon(ControlsIcon)
// .child(
// S.document()
// .schemaType(blogId)
// .documentId(blogId)
// .title("Blog Overview & Settings"),
// ),
S.listItem()
.title("Compensations")
.icon(HeartIcon)
Expand Down
36 changes: 0 additions & 36 deletions studio/lib/interfaces/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,3 @@ export interface SEO {
description: string;
imageUrl?: string;
}

export type Category = {
_key: string;
_type: string;
name: string;
};

export interface BlogPage {
_createdAt: string;
_id: string;
_rev: string;
_type: string;
_updatedAt: string;
basicTitle: string;
page: string;
slug: Slug;
allPostsLabel: string;
categories: Category[];
}

export interface Post {
_type: string;
_updatedAt: string;
slug: Slug;
_createdAt: string;
_rev: string;
_id: string;
basicTitle: string;
category: string;
richText: PortableTextBlock[];
lead: {
image: IImage;
richText: PortableTextBlock[];
};
date: string;
}
32 changes: 0 additions & 32 deletions studio/lib/queries/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,3 @@ export const SEO_SLUG_QUERY = groq`
"imageUrl": seo.seoImage.asset->url
}
`;

export const BLOG_PAGE_QUERY = groq`
*[_type == "blog" && slug.current == $slug][0]
`;

export const POSTS_QUERY = groq`
*[_type == "blogPosts" && date < now()] | order(date desc)[0..11]
`;

export const COUNT_POSTS_QUERY = groq`
count(*[_type == "blogPosts" && date < now() && (!defined($category) || category == $category)])
`;

export const CATEGORIZED_POSTS_QUERY = groq`
*[_type == "blogPosts" && date < now() && (!defined($category) || category == $category)] | order(date desc)[$start..$end]
`;

export const POST_SLUG_QUERY = groq`
*[_type == "blogPosts" && slug.current == $id][0]
`;

export const SEO_POST_SLUG_QUERY = groq`
*[_type == "blogPosts" && slug.current == $id][0]{
"title": basicTitle,
"description": richText,
"imageUrl": image.asset->url
}
`;

export const MORE_POST_PREVIEW = groq`
*[_type == "blogPosts"] | order(_createdAt desc)[0..2]
`;
6 changes: 0 additions & 6 deletions studio/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ import companyInfo from "./schemas/documents/admin/companyInfo";
import companyLocation from "./schemas/documents/admin/companyLocation";
import defaultSeo from "./schemas/documents/admin/defaultSeo";
import legalDocument from "./schemas/documents/admin/legalDocuments";
import blog from "./schemas/documents/blog";
import compensations from "./schemas/documents/compensations";
import languageSettings from "./schemas/documents/languageSettings";
import pageBuilder from "./schemas/documents/pageBuilder";
import posts from "./schemas/documents/post";
import brandAssets from "./schemas/documents/siteSettings/brandAssets";
import brokenLink from "./schemas/documents/siteSettings/brokenLink";
import locale from "./schemas/documents/siteSettings/locale";
import navigationManager from "./schemas/documents/siteSettings/navigationManager";
import socialMediaLinks from "./schemas/documents/siteSettings/socialMediaProfiles";
import customerCasesPage from "./schemas/documents/specialPages/customerCasesPage";
import callToActionField from "./schemas/fields/callToActionFields";
import categories from "./schemas/fields/categories";
import { richText } from "./schemas/fields/text";
import benefitsByLocation from "./schemas/objects/compensations/benefitsByLocation";
import { footerSection } from "./schemas/objects/footerSection";
Expand All @@ -34,9 +31,6 @@ export const schema: { types: SchemaTypeDefinition[] } = {
socialMedia,
footerSection,
callToActionField,
blog,
posts,
categories,
legalDocument,
compensations,
customerCasesPage,
Expand Down
Loading

0 comments on commit 831e47f

Please sign in to comment.