This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var newList = new List<Product>(); | |
| foreach (var (index, product) in products.Index()) | |
| { | |
| newList.Add(new Product(product.Name, index)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foreach (var item in products) | |
| { | |
| var index = products.IndexOf(item); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| products.AggregateBy( | |
| product => product.Name, | |
| seed: 0.00m, | |
| (currentTotal, product) => currentTotal + product.Price) | |
| // Laptop = 999.99m | |
| // Smartphone = 699.99m | |
| // Headphones = 299.98m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var products = new List<Product> | |
| { | |
| new Product("Laptop", 999.99m), | |
| new Product("Smartphone", 699.99m), | |
| new Product("Headphones", 199.99m), | |
| new Product("Smartwatch", 249.99m), | |
| new Product("Tablet", 329.99m), | |
| new Product("Camera", 499.99m), | |
| new Product("Printer", 149.99m), | |
| new Product("Monitor", 179.99m), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dotnet new umbraco --name YOUR_PROJECT_NAME_GOES_HERE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dotnet new install Umbraco.Templates::14.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const POST_GRAPHQL_FIELDS = ` | |
| sys { | |
| id | |
| } | |
| __typename | |
| title | |
| slug | |
| summary | |
| author { | |
| name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { draftMode } from 'next/headers'; | |
| import { notFound } from 'next/navigation'; | |
| import { Post } from '@/components/post'; | |
| import { getAllPostsWithSlug, getPostBySlug } from "@/lib/contentful/restSdk"; | |
| export async function generateStaticParams() { | |
| const allPosts = await getAllPostsWithSlug(); | |
| console.log('allPosts', allPosts); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { draftMode } from 'next/headers'; | |
| import { getAllPostsForHome } from "../lib/contentful/restSdk"; | |
| export default async function Home() { | |
| const { isEnabled } = draftMode(); | |
| const allPosts = await getAllPostsForHome(isEnabled); | |
| return ( | |
| <main className="flex min-h-screen flex-col items-center justify-between p-6 bg-white"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CONTENTFUL_SPACE_ID=SECRET | |
| CONTENTFUL_ACCESS_TOKEN=SECRET | |
| CONTENTFUL_PREVIEW_ACCESS_TOKEN=SECRET | |
| CONTENTFUL_PREVIEW_SECRET=SECRET | |
| CONTENTFUL_REVALIDATION_SECRET=SECRET | |
| CONTENTFUL_ENVIRONMENT=master | |
| CONTENTFUL_HOST=preview.contentful.com |