jamestagal / edtechdesigner

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

error with layouts_content_404_svelte #33

Closed jamestagal closed 1 year ago

jamestagal commented 2 years ago

Hi @jimafisk How are you going?

I wonder whether you could help me please with a recent error on my site? I recently added the Contact page back to my site but once doing so I got the following error:

❯ plenti serve
█▒▒▒▒▒▒▒▒▒ Building... 2022/08/23 00:01:01 errs.go:57: Could not create props: ReferenceError: layouts_content_404_svelte is not defined /home/runner/work/plenti/plenti/cmd/build/data_source.go on line 348

javascript stack trace: ReferenceError: layouts_content_404_svelte is not defined
    at create_ssr:1:623 (File: /home/runner/work/plenti/plenti/cmd/build.go, Line: 144)
Total build took 3.0912465s

I can't see why this would have happened because I only just copied over the same content, Roberto had in his theme's contact.json file into mine. See below.

{
    "title": "Contact Us",
    "enabled": true,
    "menu": true,
    "articleBody": "Swing by for a cup of coffee, or leave us a message:"
}

But what is intriguing about the error is it refers to the 404 svelte file is not defined. Any thoughts on this one would be much appreciated. In the meantime, I have pushed a bugfix branch so that I would not cause the site to crash.

Regards, Ben

jimafisk commented 2 years ago

Hi @jamestagal,

I'm trying to recreate this, but when I pull your main branch it builds fine on my end. It looks like the breaking change and the temporary fix are both on the bugfix branch?

I'm a little confused, adding content/pages/contact.json breaks the site but changing the menu key in a different file (content/pages/login.json) fixes the issue?

What is the menu key supposed to do? I don't see it even being used in the corresponding template: layouts/content/pages.svelte. Sorry I'm just not familiar with the underlying logic of the theme, so any context is helpful! Thanks!

jamestagal commented 2 years ago

Hi @jimafisk

Good question. Setting that menu key to true adds it to the nav menu. The context is that some time ago I couldn't get the Netlify form working and while waiting for a solution , see issue https://github.com/jamestagal/edtechdesigner/issues/17 I decided to remove the contact.json file thus not displaying it. Then more recently to get the page back again I just copied the content over from @roobyz (content/pages/contact.json file from his theme. But I can see when switching to the main branch now is it working.

Note: The goal with the login.json menu item in content/pages/login.json is to link to my Moodle LMS https://www.edtechdesigner.com/ But I am not sure how to do that in Plenit (ie route to an external page)

Ben

jimafisk commented 2 years ago

Hey @jamestagal,

You should be able to route to an external page simply by using the full domain in the link:

<a href="https://myexternalsite.com">My External Site</a>

Or if you want it to open in a new tab:

<a href="https://myexternalsite.com" target="_blank" rel="noopener noreferrer">My External Site</a>

Does that work for your site?

jamestagal commented 2 years ago

Hi @jimafisk

Thanks yes I should have been more specific.. what I am not sure about is where to insert that <a> tag as you listed above. In the navbar.svelte file I think any new json file created in content/pages/ is dynamically added to the nav menu. See below. https://github.com/jamestagal/edtechdesigner/blob/1bb8edac0a36f198cc9a435bed7f66facac5a5e4/layouts/global/navbar.svelte#L117-L129

So would I need to create a separate svelte component and add the <a> tag link? Thanks Ben

jimafisk commented 2 years ago

Could you hardcode an additional link above or below the {#each} block similar to posts? https://github.com/jamestagal/edtechdesigner/blob/1bb8edac0a36f198cc9a435bed7f66facac5a5e4/layouts/global/navbar.svelte#L109-L116

jamestagal commented 2 years ago

Yes I guess to it could work! it just doesn't match the styling of the other links in the nav.

Screen Shot 2022-09-22 at 9 32 30 pm
jimafisk commented 2 years ago

I'd inspect the element on the front and see what's different. It's likely that different classes or slightly different markup is being applied. Just let me know if that gives you trouble!