Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs]: Estimated Reading Time documentation issue #406

Closed
druwadi opened this issue Oct 29, 2024 · 2 comments · Fixed by #409
Closed

[Docs]: Estimated Reading Time documentation issue #406

druwadi opened this issue Oct 29, 2024 · 2 comments · Fixed by #409

Comments

@druwadi
Copy link

druwadi commented Oct 29, 2024

Describe the Issue
I'm attempting to setup the Estimated Reading Time feature, and I'm running into an issue. I noticed in the documentation here, the suggestion is to update the file at src/pages/tags/[tag]/[page].astro with an updated function for getStaticPaths. This suggests that you use the function in utils getPageNumbers. This looks like it used to be in the codebase but may have since been removed. Is there a better suggested way to approach implementing this feature with this removed or is the best path forward to pull the older file back into my local repository?

Proposed Changes
Update the docs to make it more clear, or provide a suggestion and I can make the pull request.

Additional Context
N/A

@hoangnguyen92dn
Copy link

Indeed. I was struggling with the issue on src/pages/tags/[tag]/[page].astro, here is the update on my end to make it works with the latest version

export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
  const posts = await getCollection("blog");
  const tags = getUniqueTags(posts);

  // Apply Promise
  const paths = await Promise.all(tags.map(async ({ tag, tagName }) => {
    const tagPosts = await getPostsByTag(posts, tag);

    return paginate(tagPosts, {
      params: { tag },
      props: { tagName },
      pageSize: SITE.postPerPage,
    });
  }));

  return paths.flat();
}

@satnaing
Copy link
Owner

satnaing commented Nov 4, 2024

Yep, the blog post is a bit outdated and needs an update.
I'll update the post later.

Thanks for pointing this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants