schema cleanup. Merged reviews into items

pull/58/head
Nilesh 2022-12-26 04:35:44 +00:00
rodzic d891ab3e4e
commit a03960b619
11 zmienionych plików z 190461 dodań i 141663 usunięć

Wyświetl plik

@ -3,7 +3,7 @@
"name": "first-round-capital",
"hname": "First Round Capital",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -15,7 +15,7 @@
"name": "hacker-news",
"hname": "Hacker News",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -27,7 +27,7 @@
"name": "farnam-street",
"hname": "Farnam Street",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -39,7 +39,7 @@
"name": "designer-news",
"hname": "Designer News",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -51,7 +51,7 @@
"name": "uxtools",
"hname": "UXTools",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -63,7 +63,7 @@
"name": "indie-hackers",
"hname": "Indie Hackers",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -75,7 +75,7 @@
"name": "reddit",
"hname": "Reddit",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -87,7 +87,7 @@
"name": "nobel-prize",
"hname": "Nobel Prize",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -99,7 +99,7 @@
"name": "booker-prize",
"hname": "Booker Prize",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -111,7 +111,7 @@
"name": "hugo-awards",
"hname": "Hugo Awards",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -123,7 +123,7 @@
"name": "elon-musk",
"hname": "Elon Musk",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -135,7 +135,7 @@
"name": "dustin-moskovitz",
"hname": "Dustin Moskovitz",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -147,7 +147,7 @@
"name": "jeff-bezos",
"hname": "Jeff Bezos",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -159,7 +159,7 @@
"name": "bill-gates",
"hname": "Bill Gates",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -171,7 +171,7 @@
"name": "mark-zuckerberg",
"hname": "Mark Zuckerberg",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -183,7 +183,7 @@
"name": "jack-dorsey",
"hname": "Jack Dorsey",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -195,7 +195,7 @@
"name": "tony-hsieh",
"hname": "Tony Hsieh",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -207,7 +207,7 @@
"name": "patrick-collison",
"hname": "Patrick Collison",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -219,7 +219,7 @@
"name": "larry-page",
"hname": "Larry Page",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -231,7 +231,7 @@
"name": "pavel-dunrov",
"hname": "Pavel Dunrov",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -243,7 +243,7 @@
"name": "max-levchin",
"hname": "Max Levchin",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -255,7 +255,7 @@
"name": "richard-branson",
"hname": "Richard Branson",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -267,7 +267,7 @@
"name": "salman-khan",
"hname": "Salman Khan",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -279,7 +279,7 @@
"name": "evan-williams",
"hname": "Evan Williams",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -291,7 +291,7 @@
"name": "mark-cuban",
"hname": "Mark Cuban",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -303,7 +303,7 @@
"name": "steve-jobs",
"hname": "Steve Jobs",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -315,7 +315,7 @@
"name": "kevin-rose",
"hname": "Kevin Rose",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -327,7 +327,7 @@
"name": "reid-hoffman",
"hname": "Reid Hoffman",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -339,7 +339,7 @@
"name": "travis-kalanick",
"hname": "Travis Kalanick",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -351,7 +351,7 @@
"name": "kevin-systrom",
"hname": "Kevin Systrom",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -363,7 +363,7 @@
"name": "daniel-ek",
"hname": "Daniel Ek",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -375,7 +375,7 @@
"name": "ashton-kutcher",
"hname": "Ashton Kutcher",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -387,7 +387,7 @@
"name": "austen-allred",
"hname": "Austen Allred",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -399,7 +399,7 @@
"name": "sheryl-sandberg",
"hname": "Sheryl Sandberg",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -411,7 +411,7 @@
"name": "satya-nadella",
"hname": "Satya Nadella",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -423,7 +423,7 @@
"name": "indra-nooyi",
"hname": "Indra Nooyi",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -435,7 +435,7 @@
"name": "arianna-huffington",
"hname": "Arianna Huffington",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -447,7 +447,7 @@
"name": "marissa-mayer",
"hname": "Marissa Mayer",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -459,7 +459,7 @@
"name": "daymond-john",
"hname": "Daymond John",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -471,7 +471,7 @@
"name": "eric-schmidt",
"hname": "Eric Schmidt",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -483,7 +483,7 @@
"name": "martha-stewart",
"hname": "Martha Stewart",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -495,7 +495,7 @@
"name": "tim-cook",
"hname": "Tim Cook",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -507,7 +507,7 @@
"name": "peter-thiel",
"hname": "Peter Thiel",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -519,7 +519,7 @@
"name": "sam-altman",
"hname": "Sam Altman",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -531,7 +531,7 @@
"name": "warren-buffett",
"hname": "Warren Buffett",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -543,7 +543,7 @@
"name": "marc-andreessen",
"hname": "Marc Andreessen",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -555,7 +555,7 @@
"name": "ben-horowitz",
"hname": "Ben Horowitz",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -567,7 +567,7 @@
"name": "bill-ackman",
"hname": "Bill Ackman",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -579,7 +579,7 @@
"name": "charlie-munger",
"hname": "Charlie Munger",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -591,7 +591,7 @@
"name": "whitney-tilson",
"hname": "Whitney Tilson",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -603,7 +603,7 @@
"name": "naval-ravikant",
"hname": "Naval Ravikant",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -615,7 +615,7 @@
"name": "ray-dalio",
"hname": "Ray Dalio",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -627,7 +627,7 @@
"name": "paul-graham",
"hname": "Paul Graham",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -639,7 +639,7 @@
"name": "keith-rabois",
"hname": "Keith Rabois",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -651,7 +651,7 @@
"name": "carl-sagan",
"hname": "Carl Sagan",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -663,7 +663,7 @@
"name": "albert-einstein",
"hname": "Albert Einstein",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -675,7 +675,7 @@
"name": "richard-dawkins",
"hname": "Richard Dawkins",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -687,7 +687,7 @@
"name": "neil-degrasse-tyson",
"hname": "Neil deGrasse Tyson",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -699,7 +699,7 @@
"name": "don-norman",
"hname": "Don Norman",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -711,7 +711,7 @@
"name": "jakob-nielsen",
"hname": "Jakob Nielsen",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -723,7 +723,7 @@
"name": "steve-krug",
"hname": "Steve Krug",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -735,7 +735,7 @@
"name": "alan-cooper",
"hname": "Alan Cooper",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -747,7 +747,7 @@
"name": "donald-trump",
"hname": "Donald Trump",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -759,7 +759,7 @@
"name": "barack-obama",
"hname": "Barack Obama",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -771,7 +771,7 @@
"name": "hillary-clinton",
"hname": "Hillary Clinton",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -783,7 +783,7 @@
"name": "angela-merkel",
"hname": "Angela Merkel",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -795,7 +795,7 @@
"name": "vladamir-putin",
"hname": "Vladamir Putin",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -807,7 +807,7 @@
"name": "george-bush",
"hname": "George Bush",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -819,7 +819,7 @@
"name": "tony-blair",
"hname": "Tony Blair",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -831,7 +831,7 @@
"name": "bill-clinton",
"hname": "Bill Clinton",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -843,7 +843,7 @@
"name": "tyler-cowen",
"hname": "Tyler Cowen",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -855,7 +855,7 @@
"name": "paul-krugman",
"hname": "Paul Krugman",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -867,7 +867,7 @@
"name": "ellen-degeneres",
"hname": "Ellen DeGeneres",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -879,7 +879,7 @@
"name": "oprah-winfrey",
"hname": "Oprah Winfrey",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -891,7 +891,7 @@
"name": "johnny-depp",
"hname": "Johnny Depp",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -903,7 +903,7 @@
"name": "woody-allen",
"hname": "Woody Allen",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -915,7 +915,7 @@
"name": "anthony-hopkins",
"hname": "Anthony Hopkins",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -927,7 +927,7 @@
"name": "morgan-freeman",
"hname": "Morgan Freeman",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -939,7 +939,7 @@
"name": "nassim-nicholas-taleb",
"hname": "Nassim Nicholas Taleb",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -951,7 +951,7 @@
"name": "seth-godin",
"hname": "Seth Godin",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -963,7 +963,7 @@
"name": "ryan-holiday",
"hname": "Ryan Holiday",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -975,7 +975,7 @@
"name": "jk-rowling",
"hname": "JK Rowling",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -987,7 +987,7 @@
"name": "george-rr-martin",
"hname": "George RR Martin",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -999,7 +999,7 @@
"name": "ernest-hemmingway",
"hname": "Ernest Hemmingway",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1011,7 +1011,7 @@
"name": "paulo-coelho",
"hname": "Paulo Coelho",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1023,7 +1023,7 @@
"name": "haruki-murakami",
"hname": "Haruki Murakami",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1035,7 +1035,7 @@
"name": "chuck-palahniuk",
"hname": "Chuck Palahniuk",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1047,7 +1047,7 @@
"name": "stephen-king",
"hname": "Stephen King",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1059,7 +1059,7 @@
"name": "nelson-mandela",
"hname": "Nelson Mandela",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1071,7 +1071,7 @@
"name": "mahatma-gandhi",
"hname": "Mahatma Gandhi",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1083,7 +1083,7 @@
"name": "joseph-stalin",
"hname": "Joseph Stalin",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1095,7 +1095,7 @@
"name": "martin-luther-king",
"hname": "Martin Luther King",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1107,7 +1107,7 @@
"name": "kevin-kelly",
"hname": "Kevin Kelly",
"description": null,
"image_url": null,
"image": null,
"tags": [
],
@ -1119,7 +1119,7 @@
"name": "matthew-mcconaughey",
"hname": "Matthew McConaughey",
"description": null,
"image_url": null,
"image": null,
"tags": [
],

Wyświetl plik

@ -6,50 +6,9 @@ class MyDB < ActiveRecord::Base
self.abstract_class = true
end
class Topic < MyDB
def as_json(options = {})
{
name: name,
hname: hname,
parent_id: parent_name,
sort_index: sort_index
}
end
end
class Creator < MyDB
end
class Item < MyDB
def as_json(options = {})
{
id: id,
name: hname,
description: description,
image: image_url,
links: links,
topics: topics,
creators: creators,
year: year,
difficulty: level,
cost: cost,
rating: rating,
tags: tags
}
end
end
class Review < MyDB
def as_json(options = {})
{
item_id: item_id,
by: by_creator,
rating: rating,
blurb: blurb,
url: url
}
end
end
class Topic < MyDB; end
class Creator < MyDB; end
class Item < MyDB; end
ActiveRecord::Base.logger = Logger.new(STDERR)
@ -74,7 +33,3 @@ end
File.open("items.json","w") do |f|
f.write(JSON.pretty_generate(JSON.parse(Item.all.to_json)))
end
File.open("reviews.json","w") do |f|
f.write(JSON.pretty_generate(JSON.parse(Review.all.to_json)))
end

297880
db/items.json

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1,7 +1,6 @@
import items_db from './items.json' assert { type: 'json' };
import topics_db from './topics.json' assert { type: 'json' };
import reviews_db from './reviews.json' assert { type: 'json' };
// import creators_db from './creators.json' assert { type: 'json' };
import creators_db from './creators.json' assert { type: 'json' };
export const io_getTopicList = () => {
return [...topics_db];
@ -31,15 +30,10 @@ export const io_getItem = (id) => {
}
export const io_getItemsForTopicAndFormat = (format, topicname) => {
let results = items_db.filter(i => i.topics.includes(topicname)).filter(i => i.links?.includes(format + "|"));
let results = items_db.filter(i => !topicname || i.topics.includes(topicname)).filter(i => i.links?.join(' ').includes(format + "|"));
return results.slice(0, 100);
}
export const io_getReviewsForItem = (item_id) => {
if(!item_id) return [];
return reviews_db.filter(r => r.id === item_id);
}
export const io_getItemsWithIDs = (ids) => {
let results = items_db.filter(i => ids.includes(i.id));
// console.log({ids}, {results});

Plik diff jest za duży Load Diff

Wyświetl plik

@ -15,7 +15,7 @@ CREATE TABLE creators (
name VARCHAR(255) PRIMARY KEY, -- readable, but url-friendly and unique name eg: bill_gates_1
hname VARCHAR(255) NOT NULL,
description TEXT,
image_url VARCHAR(1024),
image VARCHAR(1024),
tags TEXT[] NOT NULL,
links TEXT[] NOT NULL
);
@ -25,7 +25,7 @@ CREATE TABLE items (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
hname VARCHAR(1024) NOT NULL,
description TEXT, -- in markdown
image_url VARCHAR(1024),
image VARCHAR(1024),
tags TEXT[] NOT NULL, -- eg: oer, nsfw, free/paid etc
links TEXT[] NOT NULL, -- json array of {item_type|url|tags}
topics TEXT[] NOT NULL, -- json array of topic names
@ -33,19 +33,27 @@ CREATE TABLE items (
year VARCHAR(32),
level INTEGER,
cost TEXT,
rating INTEGER -- scale of 1 to 100, divide by 10 if needed
);
CREATE TABLE reviews (
item_id uuid NOT NULL,
by_item uuid REFERENCES items(id),
by_creator VARCHAR(255) REFERENCES creators(name),
rating INTEGER, -- scale of 1 to 100, divide by 10 if needed
blurb TEXT,
url VARCHAR(1024),
UNIQUE (item_id, by_item, by_creator),
FOREIGN KEY (item_id) REFERENCES items(id),
CHECK(by_item IS NOT NULL OR by_creator IS NOT NULL) -- one of the two must be present. Ideally both.
reviews jsonb DEFAULT '[]' NOT NULL, -- item:id or creator:id, rating,blurb,url
CHECK (
jsonb_matches_schema(
schema := '{
"type": "array",
"items": {
"type": "object",
"properties": {
"by_item": {"type": ["string", "null"]},
"by_creator": {"type": ["string", "null"]},
"rating": {"type": ["integer", "null"], "minimum": 0, "maximum": 100},
"blurb": {"type": ["string", "null"]},
"url": {"type": ["string", "null"]}
}
}
}',
instance := reviews
)
)
);
-- Dump from database to JSON files
@ -64,7 +72,3 @@ CREATE TABLE reviews (
-- FROM items
-- ) to '/Users/eshnil/code/learndb/db/items.json';
-- COPY (
-- SELECT json_agg(row_to_json(reviews)) :: text
-- FROM reviews
-- ) to '/Users/eshnil/code/learndb/db/reviews.json';

Plik diff jest za duży Load Diff

Wyświetl plik

@ -7,15 +7,15 @@
export let showBadge = false;
</script>
{#if item.links.includes('book|') && item.links.includes('video|')}
{#if item.links.join(' ').includes('book|') && item.links.join(' ').includes('video|')}
{#if displayType == 'video'}
<VideoCard {item}/>
{:else}
<BookCard {item}/>
{/if}
{:else if item.links.includes('book|')}
{:else if item.links.join(' ').includes('book|')}
<BookCard {item}/>
{:else if item.links.includes('video|')}
{:else if item.links.join(' ').includes('video|')}
<VideoCard {item}/>
{:else}
<GenericCard {item} {showBadge}/>

Wyświetl plik

@ -3,12 +3,12 @@
import { bookmarks } from "./stores.js"
import Review from "./Review.svelte"
import { randomCover } from './utility.js'
import { io_getItem, io_getReviewsForItem } from "../db/jsonlines";
import { io_getItem } from "../db/jsonlines";
export let itemid;
$: item = io_getItem(itemid);
$: reviews = io_getReviewsForItem(item?.id)
$: reviews = item?.reviews;
function get_tld(url){
return(new URL(url)).hostname.replace('www.','');
@ -35,7 +35,7 @@
return `https://www.youtube.com/oembed?url=${youtubeurl}&format=json`
}
$: item && item.links.includes('video|') && oEmded_image(item) && fetch(oEmded_image(item))
$: item && item.links.join(' ').includes('video|') && oEmded_image(item) && fetch(oEmded_image(item))
.then( r => r.json())
.then(data => {
oEmded_image_ytb_url = data.thumbnail_url
@ -86,16 +86,16 @@
<div class="mt-10">
<div class="mb-10 flex flex-wrap justify-start">
<div class={((item.links.includes('video|') && oembed_iframe) || (item.links.includes('wiki|')) ? 'w-full' : '')}>
{#if item.links.includes('wiki|')}
<div class={((item.links.join(' ').includes('video|') && oembed_iframe) || (item.links.join(' ').includes('wiki|')) ? 'w-full' : '')}>
{#if item.links.join(' ').includes('wiki|')}
<iframe src={wikiUrlForEmbed(item)} class="w-full h-[48rem]" title="embedded wiki"></iframe>
{:else if item.links.includes('video|') && oembed_iframe}
{:else if item.links.join(' ').includes('video|') && oembed_iframe}
{@html oembed_iframe.replace('width="200"','width="100%"').replace(/height=["'][0-9]+["']/i,'height="400"')}
{:else if item.image}
<div class="">
<img class="mr-5 mb-6 sm:w-44 sm:h-64 transform rounded-md shadow-lg transition duration-300 ease-out hover:scale-105 md:shadow-xl " src="{item.image}" alt="{item.name}" />
</div>
{:else if item.links.includes('video') }
{:else if item.links.join(' ').includes('video') }
<div class="relative mr-5 rounded-lg overflow-hidden shadow-lg">
<div class="w-80 h-60">
<img class="h-auto w-80 flex justify-center items-center border-r border-gray-500 relative" src="{oEmded_image_ytb_url}" alt="{item.name}">
@ -104,7 +104,7 @@
<svg class="h-12 w-12 text-indigo-500" fill="currentColor" viewBox="0 0 84 84"><circle opacity="0.9" cx="42" cy="42" r="42" fill="white"></circle><path d="M55.5039 40.3359L37.1094 28.0729C35.7803 27.1869 34 28.1396 34 29.737V54.263C34 55.8604 35.7803 56.8131 37.1094 55.9271L55.5038 43.6641C56.6913 42.8725 56.6913 41.1275 55.5039 40.3359Z"></path></svg>
</div>
</div>
{:else if !item.links.includes('video') && item.links.includes('book')}
{:else if !item.links.join(' ').includes('video') && item.links.join(' ').includes('book')}
<div class="sm:mr-10 w-44 h-64 relative">
<img class="w-44 h-64 mr-28 mb-6 h-auto transform rounded-md shadow-md transition duration-300 ease-out hover:scale-105 md:shadow-xl" src={randomCover(item.id)} alt="{item.name}" />
@ -148,7 +148,6 @@
<sl-menu-label>Download via IPFS:</sl-menu-label>
<sl-menu-item value={'https://cloudflare-ipfs.com/ipfs/' + type.split("|")[2].replace('ipfs:','')}>Cloudflare</sl-menu-item>
<sl-menu-item value={'https://ipfs.io/ipfs/' + type.split("|")[2].replace('ipfs:','')}>IPFS.io</sl-menu-item>
<sl-menu-item value={'https://ipfs.infura.io/ipfs/' + type.split("|")[2].replace('ipfs:','')}>Infura</sl-menu-item>
<sl-menu-item value={'https://gateway.pinata.cloud/ipfs/' + type.split("|")[2].replace('ipfs:','')}>Pinata</sl-menu-item>
{/if}
@ -222,7 +221,7 @@
</div>
{/if}
{#if item.creators}
{#if item.creators?.length > 0}
<div class="flex flex-col justify-between items-center gap-1 border border-neutral_dark py-5 px-2">
<div class="flex flex-col items-center">
<h3 class="uppercase text-xs ">Creator</h3>

Wyświetl plik

@ -11,7 +11,7 @@
}
</style>
<article class="px-3 py-4 bg-neutral_light text-neutral_dark rounded-lg text-xs w-48 max-w-sm shrink-0 md:w-full">
<h3 class="font-semibold">{review.blurb.toString().slice(0,10)}...</h3>
<h3 class="font-semibold">{review.blurb && review.blurb.toString().slice(0,10)}...</h3>
<p class="mt-2 line-clamp">{review.blurb}</p>
<div class="mt-3 flex flex-col">
{#if review.rating}

Wyświetl plik

@ -19,13 +19,13 @@
}
}
function hierarchy(topic_array, parent_id){
function hierarchy(topic_array, parent_name){
let tempmap = new Map();
// first pass to find all top-level objects
let parentids = [];
// console.log({topic_array}, {parent_id});
// console.log({topic_array}, {parent_name});
for(let i = 0; i < topic_array.length; i++){
if(topic_array[i].parent_id == parent_id){
if(topic_array[i].parent_name == parent_name){
tempmap.set(topic_array[i], []);
parentids.push(topic_array[i].name);
}
@ -34,8 +34,8 @@
// second pass for their children
for(let i = 0; i < topic_array.length; i++){
if(parentids.includes(topic_array[i].parent_id)){
tempmap.get(topic_array.find(t => t.name == topic_array[i].parent_id)).push(topic_array[i])
if(parentids.includes(topic_array[i].parent_name)){
tempmap.get(topic_array.find(t => t.name == topic_array[i].parent_name)).push(topic_array[i])
}
}
// console.log(tempmap);
@ -80,9 +80,9 @@
<sl-breadcrumb-item href="#/topics" class="title">All Topics</sl-breadcrumb-item>
{#if topic}
{#if topic.parent_id}
<sl-breadcrumb-item href={"#/topic/" + topic.parent_id}>
{capitalize(topic.parent_id.replace('-',' '))}
{#if topic.parent_name}
<sl-breadcrumb-item href={"#/topic/" + topic.parent_name}>
{capitalize(topic.parent_name.replace('-',' '))}
</sl-breadcrumb-item>
{/if}
{#if topic.hname}