Sails.js static html rendering

I want to create an application that will contain the page content provided by the web API and retrieved using knockoutjs. How do I handle the pages I want to crawl, is there a library that creates static html pages when the crawler enters the website and is properly integrated into sails.js?

It would be great if I could leave !#

out the url, but this is optional.

+3


source to share


1 answer


Here's one solution: Most major websites use this.

  • Writing to static HTML files is not a good idea.
  • There is no effective way to locate the finder

If your frontend uses pseudo pages, you can easily redirect those urls to some actual pages and use any templating engine.



If no trick is to have a div tag with all the content that is sent along with res.render. And the javascript code will remove this content.

You can also include description meta tags.

More details: 1) Add custom routes of all pages you want the crawler to notice.
2) Create another simple view template using an engine like jade or ejs.
3) Call the API functions inside, get the data and render the view
res.view('simpleView', dataFromDb);


4) There is some javascript in this view template that will hide this content.
5) Then knockout.js displays the content as usual.

+1


source







All Articles