You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context of this post. This particular article does not implement pagination, which is what I've been trying to find out. Yes, there are some examples out there that uses pagination, but they do not scale well. I haven't been able to come up with an efficient solution yet.
Let's assume that I have a bunch of markdown files, blog-1.md, blog-2.md, blog-3.md, blog-4.md, all the way to blog-n.md numbers of file, stored inside the directory blog/. I would like to sort them by their file metadata (age of birth), and use a loop to break them into multiple pages.
Now, I know that for the entire lifetime that the application is running, it will never add content dynamically, but only when a new commit is added. Is there a better way to approach this, without having to use import.glob.meta, followed by sorting by date of birth - again, based on the FrontMatter metadata, which is just pointless - I want to be able to use the file's metadata, followed by splicing items pageSize in the array by some page * pageSize position?
Yes, I know that if my posts exceed 500+ or more, it might be in my best interest to invest in switching to a database. But this isn't the type of change you can do in thin air, as you may have different priorities in real life. But the bare minimum I can do from my side is to optimize, right?
Now, what I want to know is that - is it possible for Svelte to understand that this particular for-loop is better off being turned into a static block? What I mean is that:
const a = ['a', 'b', 'c'];
{#eachaasel}
<li>{el}</li>
{/each}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Context of this post. This particular article does not implement pagination, which is what I've been trying to find out. Yes, there are some examples out there that uses pagination, but they do not scale well. I haven't been able to come up with an efficient solution yet.
Let's assume that I have a bunch of markdown files,
blog-1.md
,blog-2.md
,blog-3.md
,blog-4.md
, all the way toblog-n.md
numbers of file, stored inside the directoryblog/
. I would like to sort them by their file metadata (age of birth), and use a loop to break them into multiple pages.Now, I know that for the entire lifetime that the application is running, it will never add content dynamically, but only when a new commit is added. Is there a better way to approach this, without having to use
import.glob.meta
, followed by sorting by date of birth - again, based on the FrontMatter metadata, which is just pointless - I want to be able to use the file's metadata, followed by splicing itemspageSize
in the array by somepage * pageSize
position?Yes, I know that if my posts exceed 500+ or more, it might be in my best interest to invest in switching to a database. But this isn't the type of change you can do in thin air, as you may have different priorities in real life. But the bare minimum I can do from my side is to optimize, right?
Now, what I want to know is that - is it possible for Svelte to understand that this particular for-loop is better off being turned into a static block? What I mean is that:
gets converted to:
Is this possible in Svelte?
Beta Was this translation helpful? Give feedback.
All reactions