Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here's the page source:

```html

  {
      "#info": {
          "title": "WDR"
      },
      "subtitle": "Web Data Render",
      "title": "# WDR",
      "what": {
          "title" : "## What is WDR?",
          "description": [
              "This website is a valid **[JSON](//www.json.org/)**!",
              "Check the source code. Instead of the habitual HTML and CSS, you will see just a plain JSON with the website's information.",
              "WDR is a format to separate the website's **information** and **design**.",
              "The website is readily available to be consumed outside the browser via JSON, but also still presentable to users accessing through the web browser."
          ]
      },
      "subscribe": "I'm creating a **blog platform** using this concept. Follow me on [Twitter](//twitter.com/gpiresnt) to be notified when is ready! ",
      "how": {
          "title": "## How it works",
          "description": [
              "It works by embedding a small initiator at the end of the JSON file.",
              "For example, this is a valid JSON and web page:",
              "```{\n  \"title\": \"Example Page\",\n  \"description\": \"This is an example.\",\n  \"#render\": \"<html hidden><script src=/render.js></script></html>\"\n}```",
              "The script `render.js` receives the JSON as input and is responsible to render the page."
          ]
      },
      "usage": {
          "title": "## Usage",
          "description": [
              "First create an HTML file with the JSON information:",
              "```{\n  \"title\": \"Example Page\",\n  \"description\": \"This is an example.\"\n}```",
              "Include the initiator at the bottom:",
              "```{\n  \"title\": \"Example Page\",\n  \"description\": \"This is an example.\",\n  \"#render\": \"<html hidden><meta charset=utf-8><script src=/render.js></script></html>\"\n}```",
              "The next section explains how to create the `render.js`."
          ]
      },
      "only-data": {
          "title": "** Pure information **",
          "description": [
              "The JSON must contain only pure information without any concern about design or markup. All the design and markup required to render the page must be inside the rendering script."
          ]
      },
      "create-render": {
          "title": "## Creating a render",
          "description": [
              "Create a new javascript project and install the package `wdr-loader`:",
              "```npm install wdr-loader```",
              "Call the `loader` function to retrieve the JSON:",
              "```import loader from 'wdr-loader';\nloader(data => render(data));```",

              "Create a `render` function to handle the data and render the HTML. Below is an example using simple `innerHTML`:",

              "```function render(data) {\n    document.head.innerHTML = `\n      <meta charset=\"utf-8\">\n      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n      <title>${data.title}</title>`;\n\n    document.body.innerHTML = `\n      <section>\n        <h1>${data.title}</h1>\n        <p>${data.description}<p>\n      </section>`;\n}```",

              "The `wdr-loader` code is available on [GitHub](//github.com/webdatarender/wdr-loader) with an example."
          ]
      },
      "basic-render": {
          "title": "## Basic render",
          "description": [
              "If you don't want to create a render right now, it is available a basic render (used on this very website) to immediate use:"
          ],
          "download": "[render-basic-1.0.3.js](//webdatarender.com/dist/render-basic-1.0.3.js)",
          "instructions": [
              "Just download the script and include it on the initiator directly:",
              "```{\n  \"title\": \"# Example Page\",\n  \"description\": \"This is an example.\",\n  \"#render\": \"<html hidden><meta charset=utf-8><script src=/render-basic-1.0.3.js></script></html>\"\n}```",
              "The code is available on [GitHub](//github.com/webdatarender/wdr-render-basic)."
          ]
      },
      "remarks": {
          "title": "## Remarks",
          "description": [
              "• The page is rendered in [quirks mode](//developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode) and can present some layout differences on different browsers.",
              "• Although javascript is necessary to render the page, most search engines, like [Google](https://developers.google.com/speed/pagespeed/insights/?url=webdatarender.com) or [Bing](https://www.bing.com/webmaster/tools/mobile-friendliness), will be able to read the page correctly.",
              "• If you want to display the JSON for users that have javascript disabled, you can include `noscript` at the initiator: ```<noscript><style>html{display:block !important; white-space:pre}</style></noscript>```"
          ]
      },
      "support": {
          "title": "## Need Help? ",
          "description": "If you need help, have any feedback or just want to say hi, send me an [email](mailto:[email protected])."
      },
      "about": {
          "creator": "Created by [@gpiresnt](//twitter.com/gpiresnt)",
          "logo": "![logo](/img/logo.png)"
      },
      "#render": {
          "_": "<html hidden><meta charset=utf-8><script src=/dist/render-basic-1.0.3.js></script></html><noscript><style>html{display:block !important; white-space:pre}</style></noscript>",
          "css": "css/main.css"
      }
  }
```


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: