- Podcasts
- CodingCat.dev Podcast
- Code with CodingCat.dev: SvelteKit with Notion CMS
Code with CodingCat.dev: SvelteKit with Notion CMS
CodingCat.dev Podcast
- June 30, 2024
- 1 h 40 min
- Episode 1
About this episodehttps://codingcat.dev/podcast/sveltekit-with-notion-cms
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Code with CodingCat.dev: SvelteKit with Notion CMS
Oh. Cool cats I. Think I have that in a promo somewhere. Hey, cool cats. Nice, yeah. So if you can't tell, this is our very first live coding. We're trying to do it through Cream Yard and I unfortunately am down to a single monitor, so we might have to bear with me on how the code looks and things like that, but we promise we will improve as we go along here.
And we're also trying to get everything installed and running in the background. So we're a little behind, but hopefully we'll catch up very quickly. So Brittany's going to kind of show me, teach me a little bit of Svelte Kit and why I'd say a little bit like just teach me everything you know, 'cause you're awesome.
And hopefully, if we get enough time, we'll hook up some Notion back end to Svelte Kit and make some pages some. Yes that sounds great. I just realized that stream yard posts to everything. All the things. On all the things, James has got a yo look at that love the love the Twitch. We'll have to we'll have to check out Twitch some more all right, so First things first.
Like I said, this is a little rough, but here is kind of how I'm thinking we can do our screen share for now. At moments I might go full screen, but then I can't see like Brittany talking to me. So it'll be a little more difficult, but I think we'll I think we'll manage. So Brittany told me the first thing I need to do is to do MPM and hit spelt. Spelt at next and name your project should. We call this like.
Where should we create your project? Yeah, that works. We want a skeleton project just to get a base thing in there, and I'm going to let you choose to pick TypeScript or not. Oh, you know me. I know. And then obviously we want you a slant and prettier probably for ours. And then they have this new playwright browser testing so.
Playwright. I mean, we don't. It configures it for you. You don't have to use it. OK, let's do it. But it sets everything up so and now. Be useful for when we go into like our more advanced svelt course that we're going to create. I'm not doing the testing part of it, you can jump on that. I knew you'd say that.
Awesome. OK, so CD into CCD. Oops. No, that's our main one. That's the. Wrong thing. Up, up. That's spelled. Spelled Kit. We have a lot of coding cat dove repos in there. Wait, two-minute. I was going through my Firebase projects and because I was writing a project to manage fire race projects, I could create them on the fly. And I have like, it's ridiculous. Like so many.
OK, so I did that thing. I did this thing. Looks like you have to do this separately like you can't. I mean, you don't have to do that. That just goes ahead and sets up your. You need an extra quote there on the end that sets up your get Annette for you and your, adds your first initial commit and gets all that set up. But you did.
We ever like decide as a like development community that we need something more than an initial commit. I don't know, but I just realized that you you're in a mono repo, right? Well, this is hang on, let me, let me do this. Are you is that web folder, is that our main CCD or what is? We're just we're just going to hang out directly in this new spell kit project.
OK, so so that was totally fine. OK, so we initiated the new get thing, we just don't have it on GitHub yet. Correct. Not pushed to the cloud. We can do that though with our cool command line. GH repo create. Oh, it's a repo? How? It's, I know it. I always get it backwards too. I think I'm starting to get the hang of it. It's.
Kit, is there more to it? I feel like you don't even have to do that part. It'll prompt you. But there's some things that you can like do, and so you want to push an existing local repository and that's the path and that's the repository name. Coding Cat, Devon Spelka Yep, we always learn in public, right folks?
Hey Mac, how's it going? At what a Mac in the house? I like it. Thanks go to. How are we going to do our like without obs? How are we going to have boops and stuff? No, that's I, I don't know how we're going to get it into stream yard, but we're going to have to figure out like a routing thing. And that's what I want to work on. One of these streams is like doing. Yeah.
Overlay stream to OBS to stream yard. We can do that. I'm pretty sure we can do it. I don't know how the audio pipes through yet, that's the problem. I think it'll be fine because RTMPI think allows but yeah, another day that'll be. Fun yeah Mac, we don't have any Twitch chat redemptions yet that's what we were just talking about is we're going to try to do this Twitch thing more often and try to get our Twitch stream set up too but first we're working with Felt Kit today so. Interesting little bug by the way, on stream yard. We should let him know.
And the routes folder is similar to Next JS's pages folder, which I know coding cat is on Next JS so you're going to be familiar with that. So anything you create in the routes directory is a route. So next JS just released like this kind of inception like app version of that instead of pages. Is that a thing where I have to worry about like nested routes and things like that or?
So it's it's a call for comments. What's the proposal thing right now on Sveltkit to do that? I'm kind of against it, but you may go and voice your opinion on the matter if you want nested. So we have nested layouts. It's maybe I'm misspeaking about that because we have nested layouts, but there's this new proposal to do routing where I don't even understand it. It's like making it more explicit. So you have to have a folder and you can't do like the index dot spell file for the folder anymore. It has to be like named appropriately. But there it's a proposal that they got from Next and they're talking about adding it to spell kit. But we do have nested layout.
Sorry, I misunderstood what? You're no, no, you, you covered exactly what I was asking that's. Awesome, so we do have nested layouts though. So you could create a layout file that would wrap that index dot spell file. Do you want me to show you how to do that? Maybe let's let's finish like talking about like index and at least bring up what the heck does it look like so. Let's do MPM run dev get our server running we. Got Localos 3000.
Yeah, that, that is a very, very basic local. This is the skeleton project, so we started with absolutely nothing and if you wanted we could have done the demo project and we would have see a little bit more stuff here. Oh, it's all good. I like it. Feel free folks. If was this House of dispersed because I. Yeah, James has some redemptions where you can change his VS Code theme so he has the hot dog theme. Have you seen this?
I haven't seen the hot dog one. Though oh, it's really bad. Please don't add it. It's it's really, really bad. I like fun theme. So basically once we got this kind of spell kit area going, now I need to almost immediately like in my head, I'm going coding cat already and I'm like our main coding cat page. And maybe it's worthwhile to actually like bring it up too recent.
This is the problem with coding is that your brain goes to the biggest project possible right away. It's. Always, always. Done. I mean anybody, any developer that I know it just and it's like what should I do to scale this app? Like how many things do I need and just build it, add in things as you need.
It's jam stack philosophy. Yeah, I'm done with that. So if we if we start to compare those, so I have an app folder, there's an app that HTML here. So that kind of is the head piece. So the app dot HTML is just kind of the base bones of your application. So that's felt. Kit Head is where our head component in felt gets injected and then that body's where the rest of your spelt components get injected.
Cool. Is this very common with the? Is this the sugar syntax I keep reading about or no? No, this is not. This is just like this is literally a template file just to inject the stuff, and you barely touch this file unless you're maybe adding some links or meta tags up in the top there that you want completely on every page. So I can also add a spelt's head somewhere else if I want to do SEO in pages.
We could like mock this out, but I, I kind of want to understand if I wanted pages like our podcast has pages and then or a listing and then within that it has its own pages like this. Yes. So what you're asking for is dynamic routing. And I know you're gonna even go even farther with this permalink thing that we have and do that, which you can also do like with the.
And when you say endpoint like API endpoint. Yes. OK, cool. That's interesting. That's a that's that's a very interesting way to do that. Yeah. We'll have to think about that one as we build out this page. OK, so basically this would be our podcast listing at this point. So how do I go about fetching data? Is there a get static props?
What does that look like? So you would just create a script tag. OK. And and help kit you. Yeah. So this is the interesting part. So if you want to fetch something on the server, you do it in an endpoint. So we would create an index dot JS or TS file. But if you wanted to fetch it on the client, we could do it in a script context module inside of the index dot spell file.
And I love the term shadow endpoints, which is what they were called in the request for comments and. Rich talked about that, right? Yeah, we did. So page endpoints are when the endpoint corresponds to the name of your route. So you have an index dot spelt file and an index dot TS file. So auto magically under the scenes, whatever this index dot TS file returns is going to be imported into the props of the index dot spelt file without you doing anything. Cool, so basically I need to do something like this. Interesting.
What is this Lib? Is this like a? If rich hates it, I mean I'm sorry I can be anti rich for a minute. Can I? Could I? Can I have my own opinion? You're going to get fired from spell. Oh, no, I'm going to get cancelled, right? Yeah, if. You're going to get cancelled. Cancel culture. Please don't cry, everybody.
We're a little giddy. So what's this lip thing all about? So these are aliases in spell kit, so these come the dollar sign Lib comes by default, but you can configure your own aliases, which I do in my repos. I set it as an AT because I like the readability of AT Lib. So this is the equivalent of us doing things like that with that. Exactly, and I even take that slash out. So I do like at Lib slash and then what type of? Thing.
That's how I remember this one. There's components and you can do it. It dot scope dot dev is where I'm looking docs and need to find alias I think. It's I think it's right here on the screen, so it looks like instead. Of. Doing utility or something I could do like at. An AT symbol and you might have to put it in quotes for the Jason to Yep. And then you do that and sometimes VS Code freaks out on you.
If VS Code freaks out on you, then you add it to your TS config. But I wouldn't even bother right now unless it just keeps yelling at you that these files don't exist. So the reason that Lib is there is because Lib is kind of a convention in spell kit. It's not something that you have to use, but Lib is kind of where everything lives, like utils, components.
If you started up the demo app, that's where. Should should I do it that way so people don't get confused? It's a personal preference. It's not a you must do it this way. It's just a convention that OK. Hey, just FYI, everyone watching just want to know, gosh, you, you guys are on it today. I if you're having a hard time seeing the code, let me know. I'll go full screen.
So do you do? Can I help you get something up on dock so I can run outside real quick? The only thing I'm kind of wondering if if I call services from here, I'll figure it out, no. No, no, hang on. So I need to tell you something. So in those endpoints, those are Http://methods. So you have git POST, DELETE, update.
I don't remember all of them, but those are export construction git for a git request. So in your endpoint so it says like export async function get right there in the endpoint stock that you're on. Am I going to then like fetch that in? Here, yes, in inside there. So you're doing a GET request and you're going to fetch inside of that.
So I don't write server side code in that spell. Later, Anthony All. In here. You do it all in the endpoint if you want it to be server side. And OK, there may be some more that we have to do with that, but I'll have to look into that in just a minute. OK. But yeah, go. I'll be right back. We'll see you in a minute.
Oh, it did work. I'm crazy. OK, So I think what we can do, because I have all of our all of our Notion stuff kind of done already for our podcast, I think I can pull that over. So if I go to our services folder, I have this notion service file already created which is cool. Should be able to drop that in.
But it doesn't like this this. OK, now we're in business. So it sounds like for from an endpoint perspective. Oh, man, I've had to use TypeScript on a recent work project. I've managed to avoid it. So that, that is funny, Anthony. I love TypeScript. It saves my behind often. But I know there's a love hate for me and I am not shy to throw the any in.
Whereas there's so many people that would hate me right now in the TypeScript world 'cause I'm like, I just need to get it done. But most of the time I try to try to stick with strict until I just hit a wall. OK so I'm trying to figure out from a route standpoint if I do a page endpoint and instead of like this set up I just want to list items on a page. I I think I can still just use a git like this so I guess we'll see.
I wish there was typing in here but it doesn't look like there is. So I'm just like I said I'm I'm going to cheat anyways and just do this for now. So prams, I guess pipes request handler. Is that maybe a thing? Let's see here. Oh no, I see what? What's going on there? That's interesting. Gotta love live coding.
Let's see here to the page props. OK, that's cool. I like that's gonna pass that into the page. It's interesting working in a separate file to do this stuff. I'm like next. So I've gotten too used to that. So what I'm going to do for this one at our Notion side, I'm gonna have to clean some things up over here too. But for now, let's see if we can get just some of our pages going.
So basically I need to get. I don't remember the name of that format posts everybody published. This is what we're looking for. So this will give us a listing of any one of our pipes. I'm guessing I need to do some installs first. So because we are calling the Notion API, what I'm going to do is the NPM install.
Shout out to the Notion folks. Thank you for finally releasing an API. It's been awesome, especially since we did all of our podcasts in Notion. So just to show you a little behind the scenes of what our our daily looks like, we often will sit down in the morning, Britt and I and just talk about like what streams we have coming up and things like that. And then this is our our list that we go to for people coming up that are scheduled, people that are just about to come on. Like Greg, we finished yesterday. So that should go and recorded and basically anything that has passed recorded and we're finished with and all of the like editing is done inside of Notion on this page here. We will then release it and once it's in that published state or released state, we're good to go. So actually, that brings up a good point. I'm thinking that I copied the wrong one 'cause this perfect dev has a little bit of sorts to it. Perfect stream by released.
OK, so let's do that and then instead of our DB get prams ID, what we're going to do, because I don't need to get a parameter item return item. I think all I have to do is that's the posts or whatever. I'll just call posts equals and we're going to give it a page. Size of it doesn't matter for this, so let's just do 10,000. We'll get them all.
Then I think what it's saying is I can return an entire list of items. So if posts return posts, I think that's the long and short of it. I don't know how to do environment variables. So if anyone, I see Ben Myers, if anyone knows how to do environment variables, we'll definitely throw me a comment, but in the meantime I will look it up.
Let's see yarn Ed. Yeah, OK, that's that's what I was thinking. So let's do that. I'm not going to use yarn. You can kill me later, but NPM installed SD dot N OK, and then it looks like we just need process and variable. So let's do that is gonna have to go in here so we have way too much clean up because I have all kinds of types. We didn't move over with this so we might have to ignore some things and start from scratch.
Format all our posts and now we have query by released and I'm going to go down and oh, I hear Brittany, I'm going to click up. But I. Can't hear? Anything, all the rest of this up. So I'm fighting with the TypeScript at the moment, if you can hear me OK. Spotify just started playing music. I was like, what is happening?
OK, so how far did you get? Not super far. I was trying to clean up our notion file. What I what I came up to was calling our notion to get to get some posts. I think I passed those posts into the body and that's that's as far as I've gotten. So right now we were talking about how the heck do I get environment variables. OK, so environment variables are from V, but those will be exposed to the client.
So if you want to do something that's not exposed to the client, which we were talking about earlier, you're gonna do dot in the OR another package. I think dot M plus oops plus process can't type and then whatever it was, I'm going to bounce off screen for one second to drop in our super secret codes. You happen to know if that dot M can go anywhere at the root? Probably, I hope.
Anywhere yeah dot MV would go at your root. The dot MV file, is that what you're? Yeah, yeah. That goes into your root. One SEC let me find. Oh, James is saying that he hasn't gotten dot EMV to work with private variables. No, that's not it goes through. I hope not. I'm going to start. Let's let's check out it looks like Anthony has a example of it.
Cool, that's what we have. And then I think what he's saying is maybe one. Nope, it's not going to be in there dot JS dot JS. Maybe Jason has one. Yes cool, this looks awesome. Import dot NV process M were are you actually using? Maybe? Maybe this is all I need. Well, actually I think that would be the same. Then what is this complaining about object? It's possible.
There we go. OK. So let's see here. I wanna do that or something. So what am I trying to do? I wanna do this. I was trying to get the live share to work. Is that link still active? Let's do that for now. Let me check live share. Let me send it over to you. Anyone else that wants to completely mess with us I could send you the live share link. Just let me know is that.
Cool getting there. A lot of warnings. Probably another cons really adamant about using construction these days. And you better not put any's in there. Oh I know I already, I already tried to say everyone type scripts. I'm sorry. This is like for real. If you're using TypeScript, prepare for cipher code and squiggly lines. Lots of squiggly lines.
Do you like the squiggles? It will save you in production. Just FYI, I don't even need this section. We're not gonna do courses right now, so let's just. You have got so much code in like the minute that I was, well it felt like a minute. Oh, I dumped this all in from Coding Cats. So I did write this all this week though, which has been fun. Let's see here.
No, it's not work. Just kidding. Bad jokes. It's a Friday. I feel like I'm getting close. Fix all auto fixable dumb thing. OK, one more config thing. So the utilities plan, I can use that for everything right? So. It is called notion dot server dot TS. I'm very confused about what you're creating here.
Is. This like a utility thing to help OK. Yep, and I'm about to do an actual utility class or a config class as well 'cause I like that so I'm going to be. I'm getting confused with your folder structure. It it sucks, we'll talk about it. Give me one more 2nd and I think we'll be really really close to being there.
So at U did I say config? Config. There's a missing eye in there. Oh my goodness, this is what pair programming I think should have been a really big thing, don't you? Yeah, yeah, I think it's gonna be in the future. I. Don't know it costs too much people say, but I think it saved a lot of production bugs personally.
Thanks there. All right, so for those who are completely lost, basically I'm just trying to get to the point where we are able to call Notion pretty easily and we can talk about like what is happening in it. So we just don't waste a ton of time doing that. And then Brittany will get me back to Sveltiness and hopefully we can we can build off that. Looks like I have this right here is what we are looking for. So I need to import.
Config from at config notion. Why doesn't it so? Because you named it notion dot server. Where is the spelled config again config. That's right, that's not the problem, it's that notion dot server dot TS file. So do you need like the dot server? No, this so that that part's good. We're we're already using the notion piece. Why is it mad at you?
Let's hover over that and. Yes. Cannot find module or its corresponding type declarations. This is. Do you have these felt VS Code extension? Probably not this one. Looks like you do, yeah. Sometimes this gets a little buggy for me honestly and it's just it yells at you and it's fine. So I would just ignore it for now. I'll you can try to reload your window too and sometimes that fixes it.
Up first and then. It's reload window I. Don't know if I reload the window if it'll lose you but. Oh, maybe go TypeScript server? Yeah, maybe. I did that. That didn't work. Reload is the word I'm looking for. Yeah, it did end my session, but that's fine, I can work this way today. Erasure, but either way.
So I had this working because it works within here. So this works like when I pull in services file. You know what I mean? It works inside of TS. That's it, Yeah, save it and it's not working. Is that what you're saying in the? It won't work inside of this. It's almost like because this isn't in the spelt area. I don't know, that's weird.
Am I crazy at services at config? Maybe we should just use Lib. If you ain't too high env in the Explorer, there's setting. Oh yes, that is a good call. We should do that. Oh, there is, yeah. I've heard that there's like an extension or something you can use too that will. I guess just directly a setting in VS Code, but I could be I could be right.
for sake of time. And just do a dot slash I mean. OK. That works. Only thing I haven't done is this dot env but on a Mac I don't think I need to do that for all these. So all your Windows folks need dot env. Not this guy. I'm not talking about there. We're going to do this because Alex, the other Alex or the other other Alex is suggesting it and I like that.
Oh, a star at that. You have a star at the end? Yeah. For the local, Yep. Look at that. Gone. I still will probably somehow go like this and find it. Oh, touch. It oh oh, it doesn't even find it in the. I like that. I'm going to do that for node modules next. We have 15 minutes. Oh, no, no, 45 minutes 40. 5.
Minutes. 90 minutes. Oh then I gotta go in 15, maybe in like 10 minutes. OK, so basically we have gotten nowhere except showing off how to get this started. So I what I really want to get to is now that I think we are able to get posts, I think because everything's checking out so far, sure. Because we can't see.
So maybe we should get it imported. Maybe I should tell you this felt stuff before. I yeah, exactly how do how do I, I'm gonna pull that in. So let's go back to local host 3000 there. OK, I got actually running. Your other screen, oh, it's not running, I see. Oh. Tab OK, so that is your main index dot spelt file in the routes directory, but we need the podcast, so we need to go to slash podcast. OK, so it's undefined.
Why is it undefined? I don't know. OK, because you're using an endpoint, the index dot TS file, and you're not bringing anything in. So a prop and spelt. It uses kind of a module thing where you import and export. So you export, let your variable name. So post is what you're bringing in. Here I export.
I use that module because it's like exporting allows other things to access it. So right now that endpoint is accessing that prop post OK and it's still not coming through. So now you need to console log it. Or what about the put some markup? Body automatically do that? Like do I have to say body or anything like that? Body and then no, that's that's the way that that works. So you put an object, return an object to the body, and then it's post, and then post should come through as. Oh, you know.
What a prop. This is failing on the. On a different I, I figured it was failing somewhere else. OK, I'm gonna, I'm gonna go off screen once is there? Can you debug easily on the server side or no I don't know. You can, I mean you can console log in there and it will console out that. I don't have any server side rendered sites. I have a static site.
I kind of wondering though in our config if I need to put that on all of this. I also OK I'm going to go off screen one SEC. Oh, yes, on all of those, those need to use dot EMV because you're using V and so you have to use like the Veat dot EMV stuff if you're exposing variables. I thought that was the one on the client side for V. No, it does it on both sides.
He's saying he would have thought it would still be processed dot EMV, yeah. I feel like the same. So the reason I'm off screen. I'm going to console log the config and see if it's actually producing anything. OK, console log config. I didn't know we were going to be going so far into the EMV and server side stuff today.
I would have done a little more research. So that came out as a object. Instead of an array. Instead of a string. Actually is kind of what I was expecting. Oh Yep, Anthony was saying V has the whole import dot meta thing, but it will take your environment variables from the server so you can use them on the server, but they're also exposed to the client.
So endpoints and spelt run on the server and then run again on the client with V Somehow I don't really understand how all that works. But they don't stay private is the big thing that you need to take from that. So don't use the V environment variables. And James also scared me because he didn't get private environment variables working. I completely agree with that.
But Anthony had that link I didn't. I need to get. That yeah, I have it open right here. It's it's the same. I don't know what the dot EMV slash config actually does though. Maybe that's what's that's what's going wrong. Why am I not able to? OK, I'm going to show this without any of the console log.
Did you import dot EMV config? That's what I'm wondering, if I'm importing this incorrectly. Things are breaking down at my house. I'm wondering if I need to do it like that. Can you even hear like the backyard stuff going on right now? You can't. From some of it, not all of it. I wish I could take everyone on a tour of my backyard right now.
Whoops. What is? No really what is this whole dot EMV? I'm kind of wondering if I just don't use it if it would work. I'm surprised it's not just pulling in process environment. It blows my mind. I'm going to try pulling up that GitHub repo. I agree with the whole thing with James. Maybe maybe we we need to write up a post on how to get these environment variables in.
We're not even, we're not even making the call correctly yet. So we're not that far yet. Are you laughing because I said it's kind of weird? It's really weird syntax. I don't like it. Bounce off again and see if this console log will actually work. OK, so when I do that, and I'll show this because it didn't actually work, this comes out as objects and that's kind of the next step of.
I need to figure that out. Well, that looks like that needs to be parsed. I'm wondering if that env is not coming in correctly if it's coming out with that object like that. The weird thing is, anytime I like reload it doesn't console log every time, which I find is very bizarre. Like hot module reloading isn't working and isn't console logging every time.
I love it. Thank you for sticking with us. Change to. Yeah, I had it that way. That's for interest. I might pop back on in a minute, but I have to run to the bus stop to pick my kids up from the last day of school. I have so much. Going. No, they probably don't, but they'll probably yell at me when they get home if I don't so.
Oh yeah, I think by the time you get back we might have this fixed. OK. Thank you Anthony and James for. I agree with that, but the problem at that point is process. CNV does not come in then. I will be back in a few. Bye. So the the problem, Anthony, maybe I should invite you to the stream so we could talk more directly. What do you think?
Are are you available? Anthony? If you are, I'll send you the stream yard link and everyone can see it anyway, so feel free to join. Apparently Britt's doing stuff. I'm gonna, I'm gonna take her off. I feel like this should work no matter what. OK, OK, let's let's start all over. OK, so you're saying I don't need what? So you need import dot UV.
OK, we might get some more joiners. It looks like I I need some some actual help from real programmers. So at this point all we're trying to do is get these processing these look at that. There he is just like that like ask for help when they arrive. It's amazing rock. So I've copy and pasted the same snippet like 10 times and you're you're not actually doing it the way I'm writing it. I can't copy the darn like when you write it so it says import and then are you just saying?
That's it. No, I'm saying don't import from anything. Yeah. This. Yes. And then get rid of dot EMV online for like just have the process dot EMV dot Notion token, like you don't need any of those dot Emvs in there. Yeah, what you could do is you can set all of them to process dot UV, do all the tokens at once. But let's not worry about that yet. Let's just get this to work, All right? See what happens.
So this is still not like working when I console log just even this like if I just write that forget this whole like config thing undefined. OK, so go to your. Package dot Jason and then your type. Module, OK, give me one second. Are they actually set in your dot EMV file? You know what does it have to be called? A dot EMV or dot EMV?
Boom, boom. All right, Got. It. You are amazing, thank you. Sweet. Feel free to stick around. I don't know when Brittany's coming back. This whole bus stop. Thing How long are you shaving for? We got another half hour ish we're trying to do like 90 minutes yes James, it worked. So if if you're you're wondering, we renamed it to a dot env file I had as dot envy local.
So the import, we just imported the entire package it looks like directly. So if we take a look at that, it has a top level export for their TS. That's why that came in. We removed all the plus things and then just got this. I don't know if that dot envy will take care of Windows 'cause I know Windows with like slashes and and whatnot, it hates it. But let me know.
We're going to obviously stick this out in the open source world and we'll go from there. So at this point now I really need Britney back because I need to do, let's see here this, my token is invalid. So let's go back into our index podcasts check this. All right, So that is that problem hopefully. So podcast has unused export called post if it's for external reference only, OK.
So I think at this point we can start to use podcast within this page. Nice. Yes, definitely take a look. OK, so I don't know how to do this part, so let's let's take a look. I don't know if I can just like a console log. It'll probably show up. Oh, not up there It won't. Let's do this. At least then we should be able to see something. I would hope sweet.
The the irony of all this, if you're watching this, we have a new course out in coding Cat and it's called Intro to Spell. And I've been so lazy. I probably really need to watch it because Brittany breaks all of this down. And so the the goal is basically to try and rewrite or like use our Notion back end that we've been using for coding Cat for just recently, because I just rewrote it kind of show that in Svelkit. And maybe we'll start using Svelkit in V everywhere. I don't know, we'll see.
Anthony is like so tired, but yet like still helping me out. This is why I love I love the LBT community. Learnville teach you guys rock anyone else? You know, development is so much fun because we can do it together like this. So basically what Anthony was saying, expression each posts as post and we should be able to do stuff with it. I don't know, I think let's just start with some divisions and see how this goes.
What's that title? Yeah, that's fine I guess. Or maybe I need to at least say it's a array. Array. Oh, I don't know that you can type it that way. Weird, I gotta get familiar with this whole like typing thing. So post as posts and then do you go like this or is there yeah, let's let's let's check that.
OK, so we've got some things going on. We got some divisions rolling in. I don't know if they divisions will work long term, but that works for us. Now I think what we'll do is actually maybe do this and then do an H ref. I don't know how this works again in SPELTS, but that would be how it works in JSX. So let's take a look at the SPELTS docs and how do you get expressions in like a href if blah blah blah component directives.
How do you do attributes? I like that spell kit as a easy search tool. Post that slug. Yep. I wonder. I don't. I don't know why Typescript's complaining. Then let's see if that worked. Division attempts to close an element that was not. Oh duh. Oh man, it's going to be one of those days. OK, so let's splash a little something good around here. I don't know if you can use style like this, but I will. Let's just do display flex.
Yep, that's an A tag with nothing in it. A tags worse post post post Alex post. Hey, look at all those links. Beautiful. OK, so we have a listing now and now comes the tricky router part. I guess I think if I can get that to work, we'll probably call this. Good. Take it RI Hope I pronounced that right.
Hello, how are you? OK, so let's go back to the old felt kit routing and see at endpoint we got pages. Let's see about page index. I think it's just going to be this. So we have podcasts and then we need just a new page slug at TS. Still don't understand this whole importing of things. Maybe I don't need to do that because I'm in the TS world. Duh.
Hey Cadar, what we're doing is buildings Feltkit with a back end of notion. And I've never used Feltkit. We had our expert on, but she had to do some kid duty. So she might join us again here in a minute. But in the meantime, the community, the Learn, Build, teach and others are helping me through this.
And right now we have a listing page for all of the podcasts, just like Coding Cat currently has all of our cards under podcasts just like this. We now have that over here. Oops. So this is, this is our listing, essentially. So on the routing side of the house, what we're doing is trying to find this, not this maybe params, prams dot ID, Yeah, that is it.
So prams actually if I can break so that just get prams. Prams comes from ID. We actually are calling that slug. I don't know if I can give the type up here to prams, prams prams prams ID and DB dot get. OK, so we'll go back to the Notion server and we should be able to get an entire page of content this time.
Oh no, because we are doing OK, so we actually need by markdown S There you go, extreme page markdown. This is what we need, which means we'll also need this. So First things first, I'm going to jump back over on this side. Let me shrink this way down. I'm learning full stack JavaScript. That's awesome.
Keep up the good work on full stack JavaScript. Learn JavaScript first. Learn like using JavaScript and Node. And then once you kind of master those, start doing the stuff like I'm doing and jump into like a framework and check that out too. OK, so essentially I didn't talk much about our, our next JS, our next JS, our our server side for grabbing Notion data.
This might look like, oh man, what are these cards and stuff like that. What this really is is kind of this data. So this is all the data that actually drives those different podcasts. And in the Notion world, what this is known as is a database. And each database, when you open a page, this is considered a page at that point. Shout out to Brandon.
I keep showing your face everywhere. OK, go ahead. And after that, all we're doing is getting those by slugs and everything like that. So that's what got us to our listing page, our listing page. Now we can serve other pages from. And so we're going to say, let's go find that page by the slug that is provided to us up here instead of an ID.
That's kind of a nicer way to look at that. So we, we have that same thing. We have our Notion client. Again, we have databases. We're going to query those specifically for Slug and make sure that we are looking for a released episode at that point, which is also what we're looking for up here. Now there's some caveats to that, like if we're doing previewing and things like that where we're actually like working on a draft post, you can set that to draft and then just go directly after anything that isn't released. That's how we handle that too.
OK, let's see. So we're going after slug. I feel like I'm missing another query here somewhere. We have format posts IS so I also need to snag. We have this mark down, so we actually do MDX from Notion. Let's see. There is a lot of stuff going on here that we probably don't need so let me jump back over the next block. So even though we can get a stream by slug, that will only get us that database level data and what we need is page data. So in this markdown, we actually call our stream or our our slug function.
So here we're saying, OK, go find the database with that slug because we don't have an ID because we're coming at it from a top level URL. So we're grabbing that link from the top and the slug that comes out of it and finding the correct post. And there might be a way to do this directly to a page the more I think about it.
So might have to do some updates there, but that's OK. What I'm going to skip for now is our perfect pick, some perfect guests. We really don't need all of that. That's a lot of data for us. So let's start skipping some things we could do page to mark down. If anyone's out there and you have seen, and I'll ask that on here.
Does anyone know of a mark down to spelt? So if we got the markdown, we could actually send the markdown string into something like that, but instead we'll just take a look at what blocks come out. So all the way down here there should be raw by slug page. Oops, I definitely took too much off somewhere. Oh right, I forgot our markdown actually comes in like this. So OK, I will leave that.
I know I need one of those. Oh boy, oh boy. I've got the call and then I've got the page. The page ID goes into ID content. OK, so we don't need guests, and this is the part that I'm missing. So from our page, from raw results, what we're actually going to do, I think this will still work, this N2M package. So I'm going to go, yeah, I'm gonna go install that really quick.
So now that we're, we've got the Notion blocks coming in and this package actually, well, we don't have the blocks, we have the correct page. And this package actually you can provide the page two and it'll go fetch the correct blocks and convert them to markdown. So here we've got the page with the page ID, these IDs for this.
I was actually building more content than we need for now. So here's our page, our results, we send that to markdown, and then the page of blocks goes into markdown string and we actually get all of that content out as a markdown string. So it sounds like we should be able to use this MD's VEX after that, but for now, we'll just console log this and check out the string that it pulls up. Perfect picks.
We don't need any of that. We don't need this either, so we can still call stream page markdown from our slug dot TS. So this will be interesting is about this. Add that. So now we're pulling our page markdown and we need to give it the correct slug params dot slug Paramus param that slug. That is a crazy mess.
This is an object called params that has a slug of string. OK, that's correct. So our item in this case, it's actually going to be a a full. So I actually concatenate the raw results along with the content. So we'll take a look at that. So I think if I'm following along with kind of the pattern here, we'll also need a slug svelt file, I think.
So I'll just copy that and rename it to slug got svelt. So we have our slug endpoint and then we have our slug svelt file. So for now what I'm going to do is try to get items and then do console dot log items or item. Sorry. All right, let's check that out. So I have no idea what that's complaining about.
Exports is not defined. Must have just needed a reload. OK, four O 4 not found. OK, So we do need more of the path in there. So I was thinking this would be a relative thing. I don't believe it is doing that. So instead of H ref post slug, what we'll do is go like go like that. Actually, we can just I don't know how we'll do it.
And then I think it will do that on the client side as well. So now we have our content all in markdown coming through. And it looks like I haven't tried this yet, but we have this MD's Vex thing. So let's try to follow along this and see if we can make this whole markdown thing work coming from Notion. Now folks, there there might be this is this is kind of the thing with like React packages versus like spelt because it's so new with spelt.
There isn't like a lot of pre canned packages like this where it's like marked down to spelt or sorry, Notion to spelt blocks. But you could write your own where you're you're taking and reading each block and saying, OK, it's AH one, I'll put AH1 tag and so on so forth. Now that I say that we probably could even skip the markdown piece and go Notion to HTML. So because of the way that spelt works, I think it would allow the whole HTML string in there.
Well, we might find another one later, but for now I think this will work. So we already proved that we could do the mark down side. What we can go back to instead of getting the mark down side, what we can do is let's write another function and get perfect stream page HTML. And so it's going to all be the same except for when we get down here, we are going to take that out, I believe, and then we'll install this package. So I'll go ahead and do that
All right, so now we've got importing. Let's take a look at what it actually exports. So either way, it works. Now down here, instead of doing this to mark down, we'll do just like this. Oh, interesting. This this actually has the page address and just import it and paste a public notion mute public notion page URL. So let's take a look.
So instead of this crazy page, let's do page dot RL. I think it was page dot URL. Yep, instead of oh, I see there, I have it here, let's do that. Now I think we can ship over all of this stuff that we want. Specifically, what I really want is this HTML piece. So instead of content, we'll ship back HTML. Oh page, let's just do this.
Yeah. So there is actual like a full page of HTML coming out. That is pretty wild. We'd probably have to chop that up a little bit, unfortunately. So I don't know that this tool is going to work perfectly, but let's let's see what it does. So I'll go over here. We have our item. Let's just do item dot HTML and see what the heck happens. OK, I think if anyone's still watching, oh, sorry, I totally missed out.
That's pretty wild. So there is our actual Notion page. How cool is that? And we're statically rendering it. That's pretty awesome. I we would probably have to kind of hack the HTML piece of this, but it's pretty awesome that that's allowed. I'm kind of curious with like our YouTube videos and stuff. I'm curious if it would automatically put those in. So let's check that out.
What I'm going to do is what is this one regaining gaming, and I'll drop in YouTube, YouTube, YouTube. There we go. Let's embed. Instead of this image, let's do embed YouTube. See what the heck happens? Check that out. How cool is that? Boom, Yep, that's right. Boom. I love it. So I know that was a little brief and a couple of hiccups, but I think unless, unless somebody's interested in like us doing something different every 90 minutes, I know like Jason Langstorff does that and we could do that too.
Happy to bring someone on and like walk through different code bits just like we did. But that was simply just getting up and running with Svelkit, calling it a back end by Notion. We did markdown from your Notion back end into Svelt. We didn't actually put that to the page, but we could have it looks like using MD's Vex. And then we actually used another package that is just designed to spit out HTML and we we're able to do that. So we have kind of this fully functioning. Well, somewhat.
There's all kinds of CSS that myself or Brittany will throw around on this thing. But for now, we can now go to podcast. We can pick a podcast maybe and it will show HTML. So that's that's how the whole thing works from soup to nuts. It was great learning experience for myself. I hope you enjoyed it.
