Added Prime Day deals to bottom of page.

This commit is contained in:
David Ball 2024-07-17 13:21:04 -04:00
parent f615e75a0f
commit d0f40b8a9f
6 changed files with 89 additions and 4 deletions

View File

@ -91,7 +91,7 @@ const brand: Brand = ALL_BRANDS.find(b => b.slug === product.brandStoreSlug)!;
<br /> <br />
</main> </main>
{product?.amazonLink && {product?.amazonLink &&
<span slot="disclaimers">As an Amazon Associate I earn from qualifying purchases.</span> <span slot="disclaimers">As an Amazon Associate I earn from qualifying purchases. <a href="https://www.amazon.com/primeday?hvdev=c&hvadid=78271555236403&hvqmt=e&hvbmt=be&discounts-widget=%2522%257B%255C%2522state%255C%2522%253A%257B%255C%2522refinementFilters%255C%2522%253A%257B%257D%257D%252C%255C%2522version%255C%2522%253A1%257D%2522&linkCode=ll2&tag=dashersupply-20&linkId=017bf44c47d82bb5305c529c1fb82bd7&language=en_US&ref_=as_li_ss_tl">Check out the latest Prime Day deals on Amazon.</a></span>
} }
</Layout> </Layout>

View File

@ -116,6 +116,11 @@ import { ALL_CATEGORIES } from '../data/categories';
</p> </p>
</div> </div>
</main> </main>
<span slot="disclaimers">
{ /* Temporarily enabled on full blast. */ }
As an Amazon Associate I earn from qualifying purchases.
<a href="https://www.amazon.com/primeday?hvdev=c&hvadid=78271555236403&hvqmt=e&hvbmt=be&discounts-widget=%2522%257B%255C%2522state%255C%2522%253A%257B%255C%2522refinementFilters%255C%2522%253A%257B%257D%257D%252C%255C%2522version%255C%2522%253A1%257D%2522&linkCode=ll2&tag=dashersupply-20&linkId=017bf44c47d82bb5305c529c1fb82bd7&language=en_US&ref_=as_li_ss_tl">Check out the latest Prime Day deals on Amazon.</a>
</span>
</Layout> </Layout>
<style> <style>

View File

@ -56,7 +56,7 @@ const isAnyAmazon = brandProducts.find(p => p.amazonLink) || false;
</ul> </ul>
</main> </main>
{isAnyAmazon && {isAnyAmazon &&
<span slot="disclaimers">As an Amazon Associate I earn from qualifying purchases.</span> <span slot="disclaimers">As an Amazon Associate I earn from qualifying purchases. <a href="https://www.amazon.com/primeday?hvdev=c&hvadid=78271555236403&hvqmt=e&hvbmt=be&discounts-widget=%2522%257B%255C%2522state%255C%2522%253A%257B%255C%2522refinementFilters%255C%2522%253A%257B%257D%257D%252C%255C%2522version%255C%2522%253A1%257D%2522&linkCode=ll2&tag=dashersupply-20&linkId=017bf44c47d82bb5305c529c1fb82bd7&language=en_US&ref_=as_li_ss_tl">Check out the latest Prime Day deals on Amazon.</a></span>
} }
</Layout> </Layout>

View File

@ -41,7 +41,7 @@ const isAnyAmazon = categoryProducts.find(p => p.amazonLink) || false;
<br /> <br />
</main> </main>
{isAnyAmazon && {isAnyAmazon &&
<span slot="disclaimers">As an Amazon Associate I earn from qualifying purchases.</span> <span slot="disclaimers">As an Amazon Associate I earn from qualifying purchases. <a href="https://www.amazon.com/primeday?hvdev=c&hvadid=78271555236403&hvqmt=e&hvbmt=be&discounts-widget=%2522%257B%255C%2522state%255C%2522%253A%257B%255C%2522refinementFilters%255C%2522%253A%257B%257D%257D%252C%255C%2522version%255C%2522%253A1%257D%2522&linkCode=ll2&tag=dashersupply-20&linkId=017bf44c47d82bb5305c529c1fb82bd7&language=en_US&ref_=as_li_ss_tl">Check out the latest Prime Day deals on Amazon.</a></span>
} }
</Layout> </Layout>

View File

@ -21,7 +21,7 @@ import { getProductsForCategoryId } from '../data/products';
))} ))}
</ul> </ul>
<p class="instructions"> <p class="instructions">
We choose brand names you can trust. We choose brand names you can trust. As an Amazon Associate I earn from qualifying purchases.
</p> </p>
<ul role="list" class="link-card-grid brands"> <ul role="list" class="link-card-grid brands">
{ALL_BRANDS.map(brand => ( {ALL_BRANDS.map(brand => (
@ -31,6 +31,11 @@ import { getProductsForCategoryId } from '../data/products';
))} ))}
</ul> </ul>
</main> </main>
<span slot="disclaimers">
{ /* Temporarily enabled on full blast. */ }
As an Amazon Associate I earn from qualifying purchases.
<a href="https://www.amazon.com/primeday?hvdev=c&hvadid=78271555236403&hvqmt=e&hvbmt=be&discounts-widget=%2522%257B%255C%2522state%255C%2522%253A%257B%255C%2522refinementFilters%255C%2522%253A%257B%257D%257D%252C%255C%2522version%255C%2522%253A1%257D%2522&linkCode=ll2&tag=dashersupply-20&linkId=017bf44c47d82bb5305c529c1fb82bd7&language=en_US&ref_=as_li_ss_tl">Check out the latest Prime Day deals on Amazon.</a>
</span>
</Layout> </Layout>
<style> <style>

75
src/types/deep-array.ts Normal file
View File

@ -0,0 +1,75 @@
export class DeepArray<T> extends Array<T> {
public constructor(array: T[]|Array<T>|DeepArray<T>) {
// console.log("Constructing DeepArray<T> with array =", array);
super();
this.push(...array);
}
public mapRecursive<FromT, ToT>(this: FromT[], callbackfn: (value: FromT, index: number, array: DeepArray<FromT>) => ToT, childrenPropertyName: string): DeepArray<ToT> | undefined {
if(!childrenPropertyName){
throw "mapRecursive requires parameter `childrenPropertyName`";
}
const result: DeepArray<ToT> = new DeepArray([]);
this.forEach((element: any) => {
if (Array.isArray(element[childrenPropertyName])) {
result.push(...(new DeepArray<FromT>(element[childrenPropertyName])).mapRecursive<FromT,ToT>(callbackfn, childrenPropertyName) as ToT[]);
} else {
result.push(callbackfn(element, 0, new DeepArray<FromT>(this)));
}
});
return result;
}
public findRecursive<T>(this: DeepArray<T>, predicate: (value: T) => boolean, childrenPropertyName: string): T | undefined {
if(!childrenPropertyName){
throw "findRecursive requires parameter `childrenPropertyName`";
}
let initialFind = this.find(predicate);
if (initialFind) {
return initialFind;
}
let elementsWithChildren = this.asArray().filter((x: any, index: number, array: T[]) => { return x[childrenPropertyName] });
if (elementsWithChildren.length) {
let childElements: T[] = [];
elementsWithChildren.forEach((x: any) => {
if (x[childrenPropertyName])
childElements.push(...x[childrenPropertyName]);
});
return new DeepArray<T>(childElements).findRecursive(predicate, childrenPropertyName);
}
return undefined;
}
public asArray<T>(this: T[]): T[] {
let a: T[] = [];
a.push(...this);
return a;
}
}
/**
* @example
* // How to use this module:
* // Example usage:
* type Simple = string;
* interface Complex {
* interestingProperty: Simple;
* recursiveChildren?: Complex[];
* }
* let deepArray = new DeepArray<Complex>([ { interestingProperty: 'a', recursiveChildren: [ { interestingProperty: 'b' } ] }]);
* // Example 1: Map from Complex to Simple.
* deepArray.mapRecursive<Complex, Simple>((complex) => complex.interestingProperty, 'recursiveChildren');
* // Example 2: Find an element deeply in the tree.
* let result = deepArray.findRecursive<Complex>((complex) => complex.interestingProperty === 'b', 'recursiveChildren');
*/
// How to use this module:
// Example usage:
type Simple = string;
interface Complex {
interestingProperty: Simple;
recursiveChildren?: Complex[];
}
let deepArray = new DeepArray<Complex>([ { interestingProperty: 'a', recursiveChildren: [ { interestingProperty: 'b' } ] }]);
// Example 1: Map from Complex to Simple.
deepArray.mapRecursive<Complex, Simple>((complex) => complex.interestingProperty, 'recursiveChildren');
// Example 2: Find an element deeply in the tree.
console.log("Checkpoint 3");
let result = deepArray.findRecursive<Complex>((complex) => complex.interestingProperty === 'b', 'recursiveChildren');