mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add getAppVersions eleventy function
This commit is contained in:
parent
07541ce785
commit
789b526526
1 changed files with 19 additions and 1 deletions
20
.eleventy.js
20
.eleventy.js
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
|
||||
import fs from 'fs'
|
||||
import fs from 'fs-extra'
|
||||
import replace_css_url from 'replace-css-url'
|
||||
import dotenv from 'dotenv'
|
||||
import { InlineCodeManager } from '@11ty/eleventy-assets'
|
||||
|
|
@ -43,6 +43,8 @@ function getAssetFilePath(componentName) {
|
|||
|
||||
const inlineAssetCache = new Map()
|
||||
|
||||
const appBundles = new Map()
|
||||
|
||||
module.exports = function ( eleventyConfig ) {
|
||||
// console.log('eleventyConfig', eleventyConfig)
|
||||
|
||||
|
|
@ -55,6 +57,22 @@ module.exports = function ( eleventyConfig ) {
|
|||
const cssManager = new InlineCodeManager()
|
||||
const jsManager = new InlineCodeManager()
|
||||
|
||||
eleventyConfig.addJavaScriptFunction('getAppVersions', async function ( bundleIdentifier ) {
|
||||
if (appBundles.size === 0) {
|
||||
const appBundlesFromJson = await fs.readJson('./static/app-bundles.json')
|
||||
appBundlesFromJson.forEach(([ jsonAppBundleIdentifier, versions ]) => {
|
||||
appBundles.set( jsonAppBundleIdentifier, versions )
|
||||
})
|
||||
}
|
||||
|
||||
if ( appBundles.has( bundleIdentifier ) ) {
|
||||
return appBundles.get( bundleIdentifier )
|
||||
}
|
||||
|
||||
// Bundle not found
|
||||
return null
|
||||
})
|
||||
|
||||
eleventyConfig.addJavaScriptFunction('usingComponent', async function ( componentName ) {
|
||||
// console.log('Getting component', componentName)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue