#getStaticPaths() expected event to be a string

63 messages · Page 1 of 1 (latest)

verbal socket
#

I dont know what the problem is i tried to do it like in the docs but it does not work pls help me<3

hardy yarrow
#

Can you try

params: { id: id }

verbal socket
#

it is still the same problem

hardy yarrow
#

Is id a string?

verbal socket
#

yes when i hover over it it says (parameter) id: string

hardy yarrow
#

Might want to add some console logs to make sure it's getting the right value

#

Unelss that looks right

verbal socket
#

yes that should be the right link

hardy yarrow
#

alrighty try params: { event: id }

verbal socket
#

now it gives me 404

hardy yarrow
#

progress

#

Can you show the terminal error?

verbal socket
#

Property 'id' does not exist on type '{ event: string; }'.

#

now it highlights row 30

hardy yarrow
#

oh yeah

#

change that to event

#

sorry

#

const { event } =

verbal socket
#

did that now there are no problems anymore but still if i go on the link it leads to 404

hardy yarrow
#

Any errors in the terminal with the 404?

#

(server console, not client)

#

can also restart the dev server so astro sync runs again

verbal socket
#

22:03:23 [astro:db] New local database created.
22:03:23 [astro:db] Seeded database.
22:03:28 [WARN] [router] A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /events/Kornmahlen%20in%20Maria%20Luggau.

Possible dynamic routes being matched: src/pages/events/[event].astro.
22:03:28 [404] /events/Kornmahlen%20in%20Maria%20Luggau 3ms
22:03:33 [200] / 1205ms
22:03:35 [WARN] [router] A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /events/Kornmahlen%20in%20Maria%20Luggau.

Possible dynamic routes being matched: src/pages/events/[event].astro.
22:03:35 [404] /events/Kornmahlen%20in%20Maria%20Luggau 0ms

#

i did the sync

hardy yarrow
#

maybe the file needs to be called [...event].astro I'm not to sure there, I always get foggy on the catch alls

verbal socket
#

in the docs it is with [name].astro

hardy yarrow
#

The example under that looks pretty similar to what you need here

Worth a shot to try renaming the file I think

verbal socket
#

Possible dynamic routes being matched: src/pages/events/[event].astro.
22:03:28 [404] /events/Kornmahlen%20in%20Maria%20Luggau 3ms
22:03:33 [200] / 1205ms
22:03:35 [WARN] [router] A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /events/Kornmahlen%20in%20Maria%20Luggau.

Possible dynamic routes being matched: src/pages/events/[event].astro.
22:03:35 [404] /events/Kornmahlen%20in%20Maria%20Luggau 0ms
22:09:13 [watch] src/pages/events/[event].astro
22:09:19 [WARN] [router] A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /events/Kornmahlen%20in%20Maria%20Luggau.

Possible dynamic routes being matched: src/pages/events/[...event].astro.
22:09:19 [404] /events/Kornmahlen%20in%20Maria%20Luggau 1ms

now i get this but still 404

hardy yarrow
#

<@&1129102257422610512>
I'm having a brain fart here, what is the obvious thing I'm missing?

manic mountain
#

I think this actually just got fixed in the latest version. Can you try installing 4.15.6 ?

verbal socket
#

is there a console command to update this ?

manic mountain
#

npx @ astrojs/upgrade

verbal socket
#

ok thank you i will try it

ripe plinth
#

FYI - you should probably use a slugify function on your id, so that /events/Kornmahlen%20in%20Maria%20Luggau, looks like this: /events/kornmahlen-in-maria-luggau instead.

manic mountain
#

Did that work?

verbal socket
#

Tbh i have some trouble with updating npm error code ENOENT
npm error syscall lstat
npm error path C:\Users\andre\AppData\Roaming\npm
npm error errno -4058
npm error enoent ENOENT: no such file or directory, lstat 'C:\Users\andre\AppData\Roaming\npm'
npm error enoent This is related to npm not being able to find a file.
npm error enoent

hardy yarrow
#

Are you using npm?

verbal socket
#

Yes

#

I installed IT with node.js

verbal socket
#

ok finally did it

#

i run npm install in my project but my version is now 4.15.5

verbal socket
verbal socket
#

i ran npm install and restartet i also changed the version in package.json and package-lock.json

verbal socket
#

<@&1129102257422610512> does anyone know what i did wrong?

crystal gazelle
#

I'd just npm i astro@latest etc for everything

frail helm
#

Or reboot VSC I guess

#

That does wonders

verbal socket
#

and i get an 404 if i click on the link

frail helm
#

That whole filter statement inside there seems interesting

#

I don't think you want that

#

Remember that this is static generation, so at build time these pages will be prepared, it doesn't act like a live filter

#

You should just iterate your raw events

verbal socket
#

im a little bit confused could you give me an example

frail helm
#

You take your events and find the unique tags of said events

#

You then filter out the first event for each tag

crystal gazelle
#

an example input array and output array would really help align understandings cough cough unit tests

frail helm
#

So you're only generating pages for those events, so you wouldn't be able to reach any other event

verbal socket
#

Ok i tried first thing i think i dont need to filter anything then i just want to make a site for every event i have in my db there also shouldnt be any duplicates
i tried it now with a example i saw in the docs

crystal gazelle