Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple manifests #9

Open
kotoyama opened this issue Oct 13, 2023 · 1 comment
Open

Support for multiple manifests #9

kotoyama opened this issue Oct 13, 2023 · 1 comment

Comments

@kotoyama
Copy link

kotoyama commented Oct 13, 2023

Hi there! Thank you for this plugin :)

Is there a chance to add support for multiple manifests?
I have this structure of my _data/meta.js:

require('dotenv').config()

module.exports = {
  env: process.env.NODE_ENV,
  url: process.env.URL || 'http://localhost:8080',
  en: {
    title: 'title',
    description: 'description',
  },
  ru: {
    title: 'тайтл',
    description: 'описание',
  },
}

And with this structure, I don't see any way to provide metadata to manifestData object to generate multiple manifests and associate them with the corresponding templates. Much appreciated for any help!

@kotoyama
Copy link
Author

Came up with this solution as a workaround.

// .eleventy.js

...
eleventyConfig.addPlugin(faviconsPlugin, {
  generateManifest: false,
})
// _layouts/manifest.njk

{
  "lang": "{{ lang }}",
  "dir": "{{ dir or 'ltr' }}",
  "short_name": "{{ meta[lang].title }}",
  "name": "{{ meta[lang].title }}",
  "description": "{{ meta[lang].description }}",
  "orientation": "{{ 'any' }}",
  "scope": "{{ '/' }}",
  "start_url": "{{ '/' }}",
  "theme_color": "{{ '#090d11' }}",
  "background_color": "{{ '#090d11' }}",
  "display": "{{ 'standalone' }}",
  // copy from plugin once
  "icons": [
      { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
      { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
   ]
}
// _layouts/base.njk

...

// needs eleventy i18n plugin for locale url filter
<link rel="manifest" href="{{ "/site.webmanifest" | locale_url }}"">
// make for each lang
// example: en/manifest.njk

---
permalink: /{{ lang }}/site.webmanifest
layout: manifest
eleventyExcludeFromCollections: true
---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant