jamestagal / plenti-educenter

0 stars 1 forks source link

Error when loading sortByDate into component #9

Closed jamestagal closed 2 years ago

jamestagal commented 2 years ago

Hi @jimafisk How are you going?

I am up to the forth task item https://github.com/jamestagal/plenti-educenter/issues/8 which is the events content.
So far I was able to bring the content into the events.svelte template from their nodes using the following code:

{#each allContent.filter(content => content.type === "events") as event, i}
{#if i < 3}

This works fine but when I tried adding the sortByDate.svelte component in as follows, I get an error. see below.

  {#each sortByDate(allContent.filter(content => content.type === "events"), "oldest") as event, i}
    {#if i < 3}

Error message:

██████████ Building... 2022/11/07 09:08:19 build.go:148: 
Error in Client build step
Could not get all layouts 
Can't compile component file layouts/components/events.svelte
Unexpected token (2:62)
1: <script>
2:     import { sortByDate } from "../scripts/sortByDate.svelte";}
                                                                 ^
3:     export let title, link, allContent;
4: </script> /home/runner/work/plenti/plenti/cmd/build/client.go on line 260

There is a message that it Could not get all layouts Do you know why this might be?

Ben

jamestagal commented 2 years ago

Hi @jimafisk Forget about this one.. 😃 I just saw the sytax error with the extra right curly bracket on the following line! so is all good.

import { sortByDate } from "../scripts/sortByDate.svelte";}

UPDATE I am now starting to understand the structure of Plenti better and how you can build really dynamic content...For instance, with the content that has a number of items such as the events I am combining all the json data into these end node files i.e. event-1.json etc...and then just accessing it as listed above feeding it whereever it need to go, so into and across all different templates such as into:

  1. content/events.svelte
  2. content/evert_page.svelte
  3. components/events.svelte So there is a triple whammy with this example! 😸 This is a very efficient way to build out this content because it reduces code duplication and probably better when thinking about the user experience, I mean when the author adds a new event, it automatically gets added to the index page, the main event page and all nodes pages because I have included an more events list on each of these pages too. Anyway I'm enjoying the process and learning a lot. Cheers, Ben
jimafisk commented 2 years ago

Good debugging @jamestagal :tada:

I'm glad Plenti is making sense and you're enjoying building stuff in it :). I appreciate all your testing and everything you've done to support the project. Looks like you're learning a lot throughout the process! Thanks!

jamestagal commented 2 years ago

Not a problem...I'm grateful that I can learn and contribute to just a great project....admittedly it is becoming a passion/obsession 😊
How are you going? I'm guessing you are busy...Hope everything is going well your end?

Ben

jimafisk commented 2 years ago

admittedly it is becoming a passion/obsession

Well that makes two of us :joy:

Things are good! Client work has been keeping me busy, but some of it is Plenti so that's nice. I'm hoping to find some time to tighten up some things related to the CMS soon and eventually switch over to thinking about compiler improvements, although that's probably a ways out still. How are things going with you?

jamestagal commented 2 years ago

That's great Jim. I'm good too thanks. I'm glad to see the back of the wintering weather we have been having even though we are near the end of Spring. I am lucky my employer is open to more flexible working arrangements as result of the pandemic and therefore I have been able to stay working from home 4 out of 5 days even though the pandemic is now over! Work is still busy but after Nov it should slow a little as most courses are generally wrapped up by early December! I will be looking at a break by the end of Dec 😉 which should be nice.. I might be able to dedicate more time to Plenti work 😃. Take care!

jamestagal commented 2 years ago

Hi @jimafisk You mentioned compiler improvement and I was interested to know more ...and started doing some searches to understand what a compiler does. Is the compiler you are talking about built with Go? I found an article talking about LLVM IR and Go and a library for interacting with LLVM IR written in Go so it might be something similar?

jimafisk commented 2 years ago

Ah yes it's quite confusing, there are actually several compilers involved! Go itself is a compiler that spits out a binary - in our case it's the Plenti CLI tool. The other compiler is Svelte, which takes a specific templating language and converts it into pure JS. Svelte is wonderful, but in its current form it doesn't really play all that nicely with how Plenti is structured. So we've been thinking through a bunch of different ideas to make that step more consistent and less fragile. Right now we run a V8 instance and compile components that way so the end user doesn't need NodeJS installed on their computer to run Plenti. However, that comes with limitations related to performance and ability to build cross-OS binaries (e.g. create a release for Windows). It's a pretty daunting tasks to rework this compile step, so ideally there are solutions in the community that we could leverage (like https://github.com/pintariching/rustle).