Amphtml: Allow specifying amp-story bookend JSON inline

Created on 5 Jun 2018  路  2Comments  路  Source: ampproject/amphtml

Hi,

What's the request?

You know how we load bookend from a json file placed somewhere on the server and not in the same file. Is it possible to have an option to have the bookend src from within the file.

<script id="amp-bookend" type="application/json">
{
  "share-providers": {
    "facebook": true,
    "twitter": true,
    "email": true
  },
  "related-articles": {
    "Articles": [
      {
        "title": "Pet adoption",
        "url": "https://en.wikipedia.org/wiki/Pet_adoption",
        "image": "assets/related-dogs.jpg"
      }    ]
  }
}
</script>

then do something like this: bookend-config-src="#amp-bookend"

Use case

For loading related posts based on current post category. So suppose in backend i have assigned categories to every stories, and now i want to load related stories from the category of the current story user is currently on. In current scenario i have to send a request with several parameters to load related posts, title, description, image etc which makes the process very lengthy. So instead of passing the request to some external process, if i could do all this in the same file where all the parameters are already available it will be lot easier and simple to generate bookend content.

Soon Feature Request stories

Most helpful comment

Hi @abhij89, we are laying the groundwork to allow this now. We are making a new <amp-story-bookend> tag which can specify a src attribute to achieve the current behavior. e.g.

<amp-story-bookend src="path/to/my/bookend.json"></amp-story-bookend>

However, this also opens the ability to directly embed a script tag, like the one you've mentioned:

<amp-story-bookend>
  <script type="application/json">
    /* bookend JSON goes here */
  </script>
</amp-story-bookend>

This is not available yet, but we are working to release this in the near future.

/cc @Enriqe

All 2 comments

Hi @abhij89, we are laying the groundwork to allow this now. We are making a new <amp-story-bookend> tag which can specify a src attribute to achieve the current behavior. e.g.

<amp-story-bookend src="path/to/my/bookend.json"></amp-story-bookend>

However, this also opens the ability to directly embed a script tag, like the one you've mentioned:

<amp-story-bookend>
  <script type="application/json">
    /* bookend JSON goes here */
  </script>
</amp-story-bookend>

This is not available yet, but we are working to release this in the near future.

/cc @Enriqe

Thanks @newmuis , looking forward to this. This will be an awesome upgrade.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

choumx picture choumx  路  3Comments

torch2424 picture torch2424  路  3Comments

gmajoulet picture gmajoulet  路  3Comments

sryze picture sryze  路  3Comments

radiovisual picture radiovisual  路  3Comments