Skip to content

Commit

Permalink
Fixing landingkit errors (#5)
Browse files Browse the repository at this point in the history
* Fixing the conflict for the variable names

* update props for the relevant components

* fixing the error with 'windows not defined'

* Updating tina-lock for the props changes

* moving out the post pages on root

* Adding props for the homepage

* fixing prop key issues for the fragments

* fixing the path for the posts

* removing the nested post component

* Adding workflow to publish the npm package

* update readme for new path of the helloworld component

* Replacing master to main

* updating the notes for the publishing the package

* Updating the package version
  • Loading branch information
amankumarrr authored Feb 24, 2025
1 parent 67239ad commit 4e59833
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 46 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish npm Package

on:
workflow_dispatch:
release:
types: [published]

jobs:
publish-gpr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
package_json_file: package.json

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"

- name: 📦️ Install dependencies
run: pnpm install --no-frozen-lockfile

- name: 🏗️ Build
run: |
pnpm build
- name: 🚀️ Publish to NPM
run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@ export default defineConfig({
templates: [
// include the schema definitions for the components you want to use
breadcrumbBlock(
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/master/tina-starter/public/tina/previews/breadcrumbs.jpg?raw=true"
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/main/tina-starter/public/tina/previews/breadcrumbs.jpg?raw=true"
),
logoCarouselBlock(
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/master/tina-starter/public/tina/previews/logo-carousel.png?raw=true?raw=true"
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/main/tina-starter/public/tina/previews/logo-carousel.png?raw=true?raw=true"
),
buttonBlock({
icons: AntIcons,
previewSrc:
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/master/tina-starter/public/tina/previews/button.png?raw=true",
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/main/tina-starter/public/tina/previews/button.png?raw=true",
}),
cardCarouselBlock({
icons: AntIcons,
previewSrc:
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/master/tina-starter/public/tina/previews/card-carousel.jpg?raw=true",
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/main/tina-starter/public/tina/previews/card-carousel.jpg?raw=true",
}),
imageTextBlock({
icons: AntIcons,
previewSrc:
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/master/tina-starter/public/tina/previews/image-text-block.png?raw=true",
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/main/tina-starter/public/tina/previews/image-text-block.png?raw=true",
}),
accordionBlock({
icons: AntIcons,
previewSrc:
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/master/tina-starter/public/tina/previews/accordion.png?raw=true",
"https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/blob/main/tina-starter/public/tina/previews/accordion.png?raw=true",
}),
],
},
Expand Down Expand Up @@ -292,7 +292,7 @@ config file.
- navigate to the root of the test project `cd tina-starter`
- link test project with the component package by running `pnpm link --global ssw-tinacms-landingkit`
- install all dependencies and run the project by running `pnpm i` and then `pnpm dev`
- check you can view the components at `http://localhost:3000/admin/index.html#/~/posts/explore/HelloWorld`
- check you can view the components at `http://localhost:3000/` or `http://localhost:3000/admin#/~`

#### Testing Customizations

Expand All @@ -303,11 +303,9 @@ config file.

- Update the version number in `package.json` using [Semver](https://semver.org/)
- This should indicate whether the change MAJOR, MINOR, or a PATCH
- Merge any new changes into the `master` branch to prevent snowflake npm publications
- Merge any new changes into the `main` branch to prevent snowflake npm publications
- **Note**: you do not need to merge changes to `/dist` into main
- rebuild the package with your changes by running `pnpm build`
- run `npm publish --public`
- when prompted to log into npm Navigate to **Keeper** and use the one time authentication code
- Publish a GitHub release with the same version number as the one you incremented in the file package.json at https://github.com/SSWConsulting/SSW.TinaCMS.LandingKit/releases/new

## License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "ssw-tinacms-landingkit",
"version": "2.0.1",
"version": "2.0.2",
"description": "A set of high quality react components, and compatible TinaCMS schema definitions.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/components/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const Accordion = ({ data, icons, callbackFunctions }) => {
{data.heading}
</h2>
)}
{data.body && (
{data.accordionBody && (
<p
className="py-2 text-base font-light text-gray-300"
data-tina-field={tinaField(data, "body")}
data-tina-field={tinaField(data, "accordionBody")}
>
{data.body}
{data.accordionBody}
</p>
)}
</section>
Expand Down
13 changes: 7 additions & 6 deletions src/components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,22 @@ const Breadcrumbs: FC<
const { data } = props;

useEffect(() => {
if (window?.location?.pathname) {
if (typeof window !== "undefined" && window.location.pathname) {
const paths = window.location.pathname
.split('/')
.filter((path) => path !== '');
.split("/")
.filter((path) => path !== "");

const links = getLinks({
paths: paths,
data: data,
paths,
data,
firstNode: data?.firstBreadcrumb,
finalNode: data.finalBreadcrumb,
finalNodePlaceholder: data.finalNodePlaceholder,
breadcrumbReplacements: data?.breadcrumbReplacements,
});
setLinks(links);
}
}, [window, data]);
}, [data]);
const [links, setLinks] = React.useState<React.ReactNode[]>([]);
const textColor = props?.textColor ?? 'text-[#cccccc]';
const separatorColor = props?.separatorColor ?? 'stroke-[#cccccc]';
Expand Down
17 changes: 8 additions & 9 deletions src/components/card-carousel/card-carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type CardCarouselData = {
callbackFunctions?: Record<string, () => void>;
isStacked?: boolean | null;
heading?: string | null;
body?: string | null;
cardBlockBody?: string | null;
buttons?: (Button | null)[] | null;
categoryGroup?: (CategoryGroup | null)[] | null;
cardStyle?: CardOptions | null;
Expand Down Expand Up @@ -85,15 +85,15 @@ const CardCarouselContents = ({ data }: { data: CardCarouselData }) => {
{data.heading}
</h2>
)}
{data.body && (
{data.cardBlockBody && (
<p
className='m-auto max-w-4xl py-2 text-base font-light text-gray-300'
data-tina-field={tinaField(data, 'body')}>
{data.body}
data-tina-field={tinaField(data, 'cardBlockBody')}>
{data.cardBlockBody}
</p>
)}
{data.buttons?.length > 0 && (
<div className={'mb-4 mt-2 flex justify-center gap-3'}>
{data.buttons?.length > 0 && (
<div className="mb-4 mt-2 flex justify-center gap-3">
{data.buttons?.map((button, index) => {
const onClick =
button.callbackFunction &&
Expand All @@ -103,8 +103,7 @@ const CardCarouselContents = ({ data }: { data: CardCarouselData }) => {
: {};
const buttonElement = (
<Button
className='text-base'
key={`image-text-button-${index}`}
className="text-base"
icons={icons}
callbackFunctions={callbackFunctions}
data={button}
Expand All @@ -116,7 +115,7 @@ const CardCarouselContents = ({ data }: { data: CardCarouselData }) => {
{buttonElement}
</Link>
) : (
<>{buttonElement}</>
<div key={`button-${index}`}>{buttonElement}</div>
);
})}
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/logo-carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ReactElement } from 'react';
import { tinaField } from 'tinacms/dist/react';
import { Marquee } from '../internal/shadcn/marquee';
import { cn } from '../internal/shadcn/utils';
import React from 'react';

type Logo = {
logo?: string | null;
Expand Down Expand Up @@ -76,7 +77,7 @@ export default function LogoCarousel(props: {
};

return (
<>
<React.Fragment key={`logo-fragment-${index}`}>
{logo.logo ? (
<Wrapper key={`logo-${index}`}>
<Image
Expand All @@ -92,7 +93,7 @@ export default function LogoCarousel(props: {
) : (
<Wrapper className='bg-white' />
)}
</>
</React.Fragment>
);
})}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/accordion.schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const accordionBlock = ({
previewSrc: previewSrc,
defaultItem: {
heading: "Lorem Ipsum",
body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
accordionBody: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
accordionItems: [
{
label: "Lorem",
Expand Down Expand Up @@ -83,7 +83,7 @@ const accordionBlock = ({
{
type: "string",
label: "Body",
name: "body",
name: "accordionBody",
description: "Flavour text under the block title.",
},
tabletTextAlignmentFieldSchema as TinaField,
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/card-carousel.schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const defaultCardBlock = {
isStacked: false,
heading: "Lorem Ipsum",
isH1: false,
body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
cardBlockBody: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
buttonRow: [
{
buttonText: "Lorem",
Expand Down Expand Up @@ -167,7 +167,7 @@ export const cardCarouselBlock = ({
{
type: "string",
label: "Body",
name: "body",
name: "cardBlockBody",
description: "Flavour text under the block title.",
ui: {
component: "textarea",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
ImageTextBlock,
LogoCarousel,
} from "ssw-tinacms-landingkit";
import type {
PostBlocks,
PostQuery,
} from "../../../../tina/__generated__/types";
import type { PostBlocks, PostQuery } from "../tina/__generated__/types";

interface ClientPageProps {
query: string;
Expand Down Expand Up @@ -52,14 +49,15 @@ const Blocks = ({ blocks }: BlocksProps) => {
if (!blocks) return <></>;
return (
<>
{blocks.map((block) => {
{blocks.map((block, index) => {
if (!block) {
return <></>;
}
switch (block.__typename) {
case "PostBlocksBreadcrumbs":
return (
<Breadcrumbs
key={`PostBlocksBreadcrumbs-${index}`}
data={{
...block,
//URL segment mapping is configured outside of the schema
Expand All @@ -74,10 +72,17 @@ const Blocks = ({ blocks }: BlocksProps) => {
/>
);
case "PostBlocksLogoCarousel":
return <LogoCarousel repeat={10} data={block} />;
return (
<LogoCarousel
key={`PostBlocksLogoCarousel-${index}`}
repeat={10}
data={block}
/>
);
case "PostBlocksCardCarousel":
return (
<CardCarousel
key={`PostBlocksCardCarousel-${index}`}
icons={AntIcons}
callbackFunctions={callbackFunctions}
data={block}
Expand All @@ -86,6 +91,7 @@ const Blocks = ({ blocks }: BlocksProps) => {
case "PostBlocksButton":
return (
<Button
key={`PostBlocksButton-${index}`}
icons={AntIcons}
callbackFunctions={callbackFunctions}
data={block}
Expand All @@ -94,6 +100,7 @@ const Blocks = ({ blocks }: BlocksProps) => {
case "PostBlocksImageTextBlock":
return (
<ImageTextBlock
key={`PostBlocksImageTextBlock-${index}`}
icons={AntIcons}
callbackFunctions={callbackFunctions}
data={block}
Expand All @@ -102,6 +109,7 @@ const Blocks = ({ blocks }: BlocksProps) => {
case "PostBlocksAccordion":
return (
<Accordion
key={`PostBlocksAccordion-${index}`}
icons={AntIcons}
callbackFunctions={callbackFunctions}
data={block}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import client from "../../../../tina/__generated__/client";
import client from "../tina/__generated__/client";
import Post from "./client-page";

export async function generateStaticParams() {
Expand All @@ -17,8 +17,12 @@ export default async function PostPage({
params: { filename: string[] };
}) {

let filename = params.filename;
if (!filename) {
filename = ["HelloWorld"];
}
const data = await client.queries.post({
relativePath: `${params.filename}.md`,
relativePath: `${filename}.md`,
});

return (
Expand Down
4 changes: 3 additions & 1 deletion tina-starter/tina/collections/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const blogPosts = {
],
ui: {
router: ({ document }) => {
return `/posts/explore/${document._sys.filename}`;
if (document._sys.filename === "HelloWorld") {
return "/";
}
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion tina-starter/tina/tina-lock.json

Large diffs are not rendered by default.

0 comments on commit 4e59833

Please sign in to comment.