Skip to content

Instantly share code, notes, and snippets.

View jondjones's full-sized avatar

Jon jondjones

View GitHub Profile
@jondjones
jondjones / 7 New Linq Methods You Need To Know About - 3
Created May 28, 2024 15:54
7 New Linq Methods You Need To Know About - 3
var newList = new List<Product>();
foreach (var (index, product) in products.Index())
{
newList.Add(new Product(product.Name, index));
}
@jondjones
jondjones / 7 New Linq Methods You Need To Know About - 2
Created May 28, 2024 15:53
7 New Linq Methods You Need To Know About - 2
foreach (var item in products)
{
var index = products.IndexOf(item);
}
@jondjones
jondjones / 7 New Linq Methods You Need To Know About - 1
Created May 28, 2024 15:52
7 New Linq Methods You Need To Know About - 1
products.AggregateBy(
product => product.Name,
seed: 0.00m,
(currentTotal, product) => currentTotal + product.Price)
// Laptop = 999.99m
// Smartphone = 699.99m
// Headphones = 299.98m
@jondjones
jondjones / 7 New Linq Methods You Need To Know About
Last active May 28, 2024 15:52
7 New Linq Methods You Need To Know About
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),
@jondjones
jondjones / Umbraco 14 New Features Deep-dive with Installation Masterclass - 1
Created May 28, 2024 06:59
Umbraco 14 New Features Deep-dive with Installation Masterclass - 1
dotnet new umbraco --name YOUR_PROJECT_NAME_GOES_HERE
@jondjones
jondjones / Umbraco 14 New Features Deep-dive with Installation Masterclass
Created May 28, 2024 06:57
Umbraco 14 New Features Deep-dive with Installation Masterclass
dotnet new install Umbraco.Templates::14.0.0
@jondjones
jondjones / How to Integrate Contentful and Next.js App Router - 5
Last active May 21, 2024 11:06
How to Integrate Contentful and Next.js App Router - 5
const POST_GRAPHQL_FIELDS = `
sys {
id
}
__typename
title
slug
summary
author {
name,
@jondjones
jondjones / How to Integrate Contentful and Next.js App Router - 4
Created May 20, 2024 09:16
How to Integrate Contentful and Next.js App Router - 4
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);
@jondjones
jondjones / How to Integrate Contentful and Next.js App Router - 3
Created May 20, 2024 09:14
How to Integrate Contentful and Next.js App Router - 3
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">
@jondjones
jondjones / How to Integrate Contentful and Next.js App Router - 2
Last active May 20, 2024 09:11
How to Integrate Contentful and Next.js App Router - 2
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