Unverified Commit 555838ec authored by Jam Balaya's avatar Jam Balaya Committed by GitHub

examples: fix typos in cms-agilitycms (#82504)

## Summary

Correct spelling errors in the cms-agilitycms example, including the
image prop spelling and dependency imports.

Bug Fixes:
- Fix misspelled intersectionTreshold prop to intersectionThreshold in
the Image component and its useInView configuration

Enhancements:
- Rename dependancies.ts to dependencies.ts and update
requireComponentDependancyByName to requireComponentDependencyByName
across API and component imports

### Adding or Updating Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.mdCo-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent bd2c871e
...@@ -3,7 +3,7 @@ import { CMS_LANG, CMS_CHANNEL } from "./constants"; ...@@ -3,7 +3,7 @@ import { CMS_LANG, CMS_CHANNEL } from "./constants";
import { asyncForEach } from "./utils"; import { asyncForEach } from "./utils";
export { validatePreview } from "./preview"; export { validatePreview } from "./preview";
import { normalizePosts } from "./normalize"; import { normalizePosts } from "./normalize";
import { requireComponentDependancyByName } from "./dependancies"; import { requireComponentDependencyByName } from "./dependencies";
// Our LIVE API client // Our LIVE API client
const liveClient = agility.getApi({ const liveClient = agility.getApi({
...@@ -155,7 +155,7 @@ export async function getAgilityPageProps({ params, preview }) { ...@@ -155,7 +155,7 @@ export async function getAgilityPageProps({ params, preview }) {
//loop through the zone's modules //loop through the zone's modules
await asyncForEach(modulesForThisContentZone, async (moduleItem) => { await asyncForEach(modulesForThisContentZone, async (moduleItem) => {
let ModuleComponentToRender = requireComponentDependancyByName( let ModuleComponentToRender = requireComponentDependencyByName(
moduleItem.module, moduleItem.module,
); );
......
import { requireComponentDependancyByName } from "../dependancies"; import { requireComponentDependencyByName } from "../dependencies";
export default function ContentZone(props) { export default function ContentZone(props) {
function RenderModules() { function RenderModules() {
let modules = props.page.zones[props.name]; let modules = props.page.zones[props.name];
return modules.map((m, i) => { return modules.map((m, i) => {
const AgilityModule = requireComponentDependancyByName(m.moduleName); const AgilityModule = requireComponentDependencyByName(m.moduleName);
return <AgilityModule key={i} {...m.item} />; return <AgilityModule key={i} {...m.item} />;
}); });
} }
......
...@@ -71,7 +71,6 @@ type ImageProps = { ...@@ -71,7 +71,6 @@ type ImageProps = {
className?: string; className?: string;
pictureClassName?: string; pictureClassName?: string;
fadeInDuration?: number; fadeInDuration?: number;
intersectionTreshold?: number;
intersectionThreshold?: number; intersectionThreshold?: number;
intersectionMargin?: string; intersectionMargin?: string;
lazyLoad?: boolean; lazyLoad?: boolean;
...@@ -83,7 +82,7 @@ type ImageProps = { ...@@ -83,7 +82,7 @@ type ImageProps = {
const Image = function ({ const Image = function ({
className, className,
fadeInDuration, fadeInDuration,
intersectionTreshold, intersectionThreshold,
intersectionMargin, intersectionMargin,
pictureClassName, pictureClassName,
lazyLoad = true, lazyLoad = true,
...@@ -99,7 +98,7 @@ const Image = function ({ ...@@ -99,7 +98,7 @@ const Image = function ({
}, []); }, []);
const [ref, inView] = useInView({ const [ref, inView] = useInView({
threshold: intersectionTreshold || 0, threshold: intersectionThreshold || 0,
rootMargin: intersectionMargin || "0px 0px 0px 0px", rootMargin: intersectionMargin || "0px 0px 0px 0px",
triggerOnce: true, triggerOnce: true,
}); });
......
import { requireComponentDependancyByName } from "../dependancies"; import { requireComponentDependencyByName } from "../dependencies";
export default function CMSPageTemplate(props) { export default function CMSPageTemplate(props) {
const AgilityPageTemplateToRender = requireComponentDependancyByName( const AgilityPageTemplateToRender = requireComponentDependencyByName(
props.pageTemplateName, props.pageTemplateName,
); );
return <AgilityPageTemplateToRender {...props} />; return <AgilityPageTemplateToRender {...props} />;
......
...@@ -23,7 +23,7 @@ const requireComponent = (name) => { ...@@ -23,7 +23,7 @@ const requireComponent = (name) => {
//Bug: when dynamic imports are used within the module, it doest not get outputted server-side //Bug: when dynamic imports are used within the module, it doest not get outputted server-side
//let AgilityModule = dynamic(() => import ('../components/' + m.moduleName)); //let AgilityModule = dynamic(() => import ('../components/' + m.moduleName));
export const requireComponentDependancyByName = (name) => { export const requireComponentDependencyByName = (name) => {
let pascalCaseName = name; let pascalCaseName = name;
let kebabCaseName = convertPascalToKebabCase(name); let kebabCaseName = convertPascalToKebabCase(name);
let Component = null; let Component = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment