内联Web App清单? [英] Inline the Web App Manifest?

查看:90
本文介绍了内联Web App清单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含数千个静态单页应用程序的市场/网络应用程序.

I have a marketplace/web application with thousands of static single page apps.

希望为每个页面添加 Web应用清单相应stem_url(给定SPA的所有urls的{root}/index.html)的<head> </head>标记中的应用程序.

Wish to add a Web App Manifest for each single page app in the <head> </head> tag of their corresponding stem_url (The {root}/index.html for all the urls of a given SPA).

标准方法:

<link rel="manifest" href="/manifest.json">

…似乎不是前进的好方法,因为这将意味着将成千上万个manifest.js文件转储到/public文件夹中(这是一个Rails应用程序!),最终将完成应用程序/资产的编译工作随着这个数字的增加,它变得非常沉重.

…does not seem like a good way to go forward because this would mean thousands of manifest.js files being dumped into the /public folder (it's a rails app!) and it would eventually make the app/assets compilation job very heavy as this number goes up.

有没有一种方法可以像内嵌样式标签那样内联清单json:

Is there a way we could inline manifest json just like we do the style tags:

<style>
  body { // style here }
  …
</style>

等效的清单声明:

<manifest>
 { 
   "name": "HackerWeb",
   "short_name": "HackerWeb",
   …
}
</manifest>

推荐答案

您可以使用data:url内联json.所以不是标准的

You can inline the json by using a data:url. So instead of the standard

<link rel="manifest" href="/manifest.json">

应该是

<link rel="manifest" href='data:application/manifest+json,{ "name": "theName", "short_name": "shortName", "description": "theDescription"}' />

我也想对其进行内联并立即进行尝试.有效

I wanted to inline it too and tried it just now. It works

这篇关于内联Web App清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆