Static and dynamic content in docpad system - how to create dynamic content?

DocPad is described as being comparable to other static site generators, but it is also described as "not limited to static site generation."

I was browsing the DocPad website and other documentation and still could not find anything similar to explaining how to enable dynamic content and what restrictions might be involved?

As a relative newbie, I wonder if someone can help me better understand the methodology according to which dynamic content will be included in DocPad ...? for example, AJAX and dynamic server scripts to perform tasks such as dynamically loading images from Flickr to a web page when you click a specific tag ...

Thanks.

+6
source share
1 answer

So, a few ways DocPad facilitates dynamic content:

  • Using the regenerateEvery option. This will allow you to regenerate your site as often as you specify. This is great in combination with plugins like feedr for pulling data from remote feed sources (like your last social activity), as well as a repocloner that clones and stores the git repository in your project. The advantage of this option is that it is very easy to do and creates the illusion of a vibrant website. For example, Benjamin Lupton Website uses this method to keep statistics on the home page, as well as social data on the sidebar, up to date. Every hour it is restored with the latest information. Fast creation, and also illusory dynamic.

  • Via the dynamic metadata property. If set to true , this tells the DocPad server, we must redisplay this document for each request, and not just once. This works great inside the Kitchensink skeleton for search pages and miscellaneous shapes . This method is most similar to PHP development.

  • Via serverExtend event . This event allows you to connect and expand the DocPad server, allowing you to add additional server-side logic, processing, etc. Common use cases are adding extra routing to your server to handle route aliases, adding form processing, such as a form contact, or adding a RESTULful interface to the Backbone.js application. The DocPad website uses this to add additional routing and regeneration after receiving a documentation message . NodeChat Skeleton uses this to add Socket.io server logic .

  • Through the API . This method is most in demand, but it can be very useful if you just want DocPad to be a small part of an existing node.js. With this, you can create an instance of DocPad in your code and interact with it. The grunt-docs task uses the following :)

+12
source

Source: https://habr.com/ru/post/944329/


All Articles