Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
wurd-node example
node v8.17.0
version:
1.1.0
endpoint
share
tweet
A simple Node app using the Wurd CMS client.
const app = require('express')(); const wurd = require('wurd'); wurd.connect('node-example', { editMode: true // Edit mode always on }); app.get('/', async (req, res) => { //Load a content block with accessor methods //Content is cached for subsequent requests const content = await wurd.load('shared,homepage'); //Use shortcuts for cleaner HTML templates const {text, el} = content; //Use block() for creating smaller subsets of content const footer = content.block('shared.footer'); res.send(` <html> <head> <!-- Use text() to get simple text content --> <title>${text('shared.brandName')}</title> </head> <body> <!-- Use el() to create editable text regions --> <h1>${el('homepage.title')}</h1> <h2>${el('homepage.welcome', {name: 'John'}, {markdown: true})}</h2> <footer> <a href="privacy">${footer.el('privacy')}</a> <a href="terms">${footer.el('terms')}</a> </footer> <!-- Include this line for enabling inline content editing --> <script src="https://edit-v3.wurd.io/widget.js" data-app="${content.app}"></script> </body> </html> `); }); app.listen(3000);
Loading…
no comments
sign in
to comment