jamestagal / edtechdesigner

A professional blog site of Benjamin Waller
https://edtechdesigner.io
0 stars 1 forks source link

Removing field dateModified throws an error #11

Closed jamestagal closed 2 years ago

jamestagal commented 2 years ago

Hi Jim, The field dateModified in the posts.json files seems to be required because If I remove it I get an error. However I was thinking that when posts haven't been modified it would better not to display this field. How could I optionally display the dateModified field? I tried using "false" as a value but that just displayed 'false' on the page... :) Any suggestions here would be appreciated.

jimafisk commented 2 years ago

Just make sure you check if the field exists (i.e. {#if dateModified}) before using it in a template: https://github.com/jamestagal/edtechdesigner/blob/main/layouts/content/posts.svelte#L43. Once you do that you should be able to remove the key from your content source without errors.

jamestagal commented 2 years ago

Hi Jim, ok thanks. I quickly added the following but still get an error. See below how I did it.

2022/01/02 11:59:50 errs.go:57: Can't render htmlComponent: TypeError: Cannot read property 'dateModified' of undefined /home/runner/work/plenti/plenti/cmd/build/data_source.go on line 321
   {#if dateModified}
          <li class="px-1 inline-flex">Updated : {dateModified}</li>
          {/if}
jimafisk commented 2 years ago

What you did looks right for layouts/content/posts.svelte, but it appears that dateModified is also used in:

So you'd have to copy those templates and modify them as well. Here's a working example: https://github.com/jamestagal/edtechdesigner/pull/12

jamestagal commented 2 years ago

hi Jim. ok thanks.. to start with should I merge what you have modified from this pull request? https://github.com/jamestagal/edtechdesigner/pull/12 So just to check, when doing a "Merge pull request" green button, that modifies and updates my repo with your changes., is that correct? If so, then how to I update my local repo on my machine to be in sync with Gitbub? Sorry I am still very new to git and Github :)

jimafisk commented 2 years ago

Yeah you can merge that pull request to add my changes to your repo. Couple of things to note:

That's correct, using the "Merge pull request" will modify this repo. To get your local machine sync'd up, after you merge on Github go to your local project and pull in those changes: git pull origin main

jamestagal commented 2 years ago

Wow that's really cool! I think i need to learn more about these features in Git/Github. I was able to merge your changes and then pull them down to my local repo and push back to Github really quickly :) Thanks Jim. I really appreciate all your assistance with this. I still have to finalise my content to be added and make change to the about page but thanks to you, Plenti and this theme I'm getting there. I need to swap out some images and write a few posts... etc but I'm happy with the development. I am finding it's a little hard work styling the html in the .json file particularly list items but i can see that your CMS will make this much easier :) Happy new year to you and your family.

jimafisk commented 2 years ago

Great glad you're making progress :). I agree there's a lot to be desired when it comes to maintaining content, especially unstructured WYSIWYG type fields (e.g. alternative between a blurb of text and a bulleted list). We're working on it, so it should get better with some time. Happy new year to you as well!!