question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hook backend APIs for stars/comments/reads

See original GitHub issue

Hi all,

I’m new to nuxt content and I am trying to build a personal blog with stars / comments / reads. Since nuxt content is generating static files, how can make it work with an express backend for storing stars / comments / reads?

I’m planning to use express talk to a mongo db for storing the stars / comments / reads.

One way I can think about is to use slug as the identifier of an article, and fetch db using this as article id. However if I end up changing the name of the slug, all the backend data will be messed up.

Is there a way the nuxt content apis can call my backend apis to decorate the response?

Any suggestions will be very helpful!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TheLearneercommented, Sep 25, 2020

I guess I am late at this but seeing the issue open I just though of sharing my point of view as well… Just like Atinux said, you can include a unique ID in the front matter and use it. THATS THE WAY FOR YOU TO GO

I have done something similar with my personal bog as well. but instead of setting id in front matter I have used the slug as the unique id itself (because I am naming every file uniquely)

https://github.com/TheLearneer/santoshb.com.np/blob/master/pages/blog/_slug.vue#L75 https://github.com/TheLearneer/santoshb.com.np/blob/master/pages/blog/_slug.vue#L121-L127

Also I am using disqus commenting system but still everything you are telling accounts.

1reaction
jogjechcommented, Aug 10, 2020

You can use something like this:

  hooks: {
    'content:file:beforeInsert': (document) => {
      if (!document.postid) {
        document.postid = randomID()
      }
    }
  }

I tried this approach but the randomId will be changing everytime I update the content of the .md file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Popular backend APIs - Back4App Blog
This article lists some popular backend APIs including Firebase, Backendless, Kii, Django, etc.
Read more >
How To Call Web APIs with the useEffect Hook in React
In this tutorial, you'll use the useEffect and useState React Hooks to fetch and display information in a sample application, ...
Read more >
Utility APIs · Backstage Software Catalog and Developer ...
To access one of the Utility APIs inside a React component, use the useApi hook exported by @backstage/core-plugin-api , or the withApis HOC...
Read more >
Connecting the frontend and the backend - YouTube
Want to learn more about how to build production grade APIs and support the channel? Buy my book on leanpub: ...
Read more >
NoCodeAPI – The easiest way to connect APIs without code
NoCode API is a great place to experiment with APIs and interact with them, ... Twitter, Telegram, Open Graph API, MailChimp, 50 +...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found