diff --git a/README.md b/README.md
index 9461d2b10..2664d3caa 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,6 @@ See the [setup guide][setup] for partials, layouts, caching, and other options.
## Used by
-
@@ -72,7 +71,7 @@ See the [setup guide][setup] for partials, layouts, caching, and other options.
-Products and projects running on LiquidJS. [Open a PR](https://github.com/harttle/liquidjs/edit/master/data/used-by.json) to add yours.
+Products and projects running on LiquidJS. [Open a PR](https://github.com/harttle/liquidjs/edit/master/README.md) to add yours.
## Financial Support
diff --git a/bin/build-contributors.js b/bin/build-contributors.js
index d2c774c91..e3a303f76 100644
--- a/bin/build-contributors.js
+++ b/bin/build-contributors.js
@@ -33,7 +33,9 @@ function transformFinancial (html) {
const allContributors = transformContributors(extractSection(readme, 'ALL-CONTRIBUTORS-LIST:START', 'ALL-CONTRIBUTORS-LIST:END'))
const financialContributors = transformFinancial(extractSection(readme, 'FINANCIAL-CONTRIBUTORS-BEGIN', 'FINANCIAL-CONTRIBUTORS-END'))
+const usedBy = transformFinancial(extractSection(readme, 'USED-BY-BEGIN', 'USED-BY-END'))
const outDir = path.join(root, 'docs/themes/navy/layout/partial')
fs.writeFileSync(path.join(outDir, 'all-contributors.swig'), allContributors)
fs.writeFileSync(path.join(outDir, 'financial-contributors.swig'), financialContributors)
+fs.writeFileSync(path.join(outDir, 'used-by.swig'), usedBy)
diff --git a/bin/build-used-by.js b/bin/build-used-by.js
deleted file mode 100644
index bb7a83e4d..000000000
--- a/bin/build-used-by.js
+++ /dev/null
@@ -1,116 +0,0 @@
-const fs = require('fs')
-const path = require('path')
-
-const root = path.resolve(__dirname, '..')
-const readmePath = path.join(root, 'README.md')
-const dataPath = path.join(root, 'data/used-by.json')
-const outDir = path.join(root, 'docs/themes/navy/layout/partial')
-
-const LINK_STYLE = 'display: inline-block; vertical-align: middle; margin: 8px;'
-const IMG_STYLE = 'vertical-align: middle;'
-const PER_ROW = 7
-
-function escapeHtml (str) {
- return String(str)
- .replace(/&/g, '&')
- .replace(//g, '>')
- .replace(/"/g, '"')
-}
-
-function websiteFavicon (url) {
- return 'https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=' +
- encodeURIComponent(url) +
- '&size=128'
-}
-
-async function githubAvatar (url) {
- try {
- const { hostname, pathname } = new URL(url)
- if (hostname !== 'github.com') return
- const owner = pathname.split('/').filter(Boolean)[0]
- if (!owner) return
- const res = await fetch(`https://api.github.com/users/${encodeURIComponent(owner)}`, {
- headers: { 'User-Agent': 'liquidjs-build-used-by' }
- })
- if (!res.ok) return
- const data = await res.json()
- if (!data.avatar_url) return
- const base = data.avatar_url.split('?')[0]
- return `${base}?s=128`
- } catch {}
-}
-
-async function resolveLogo (entry) {
- if (entry.logo) return entry.logo
- const gh = await githubAvatar(entry.url)
- if (gh) return gh
- return websiteFavicon(entry.url)
-}
-
-function imgTag ({ name, src, width, height, imgStyle }) {
- const alt = escapeHtml(name)
- const href = escapeHtml(src)
- const dims = []
- if (width) dims.push(`width="${width}"`)
- if (height) dims.push(`height="${height}"`)
- else if (!width) dims.push('height="80"')
- const style = imgStyle ? `${IMG_STYLE}${imgStyle}` : IMG_STYLE
- return `
`
-}
-
-function linkTag (entry, logo) {
- const href = escapeHtml(entry.url)
- const img = imgTag({
- name: entry.name,
- src: logo,
- width: entry.width,
- height: entry.height,
- imgStyle: entry.imgStyle
- })
- return ` ${img}`
-}
-
-async function renderHtml (entries) {
- const logos = await Promise.all(entries.map(resolveLogo))
- const links = entries.map((entry, i) => linkTag(entry, logos[i]))
- const lines = ['']
- links.forEach((link, i) => {
- if (i > 0 && i % PER_ROW === 0 && links.length - i > 2) lines.push('
')
- lines.push(link)
- })
- lines.push('
')
- return lines.join('\n')
-}
-
-function transformUsedBy (html) {
- return html
- .replace(/
.*?<\/td>/g, '')
- .replace(/\n/g, '')
- .replace(/<\/tr>\s*/g, '')
-}
-
-function patchReadme (html) {
- const readme = fs.readFileSync(readmePath, 'utf8').replace(/\r\n/g, '\n')
- const begin = ''
- const end = ''
- const re = new RegExp(`${begin}[\\s\\S]*?${end}`)
- if (!re.test(readme)) {
- throw new Error(`README.md is missing ${begin} … ${end}`)
- }
- const next = readme.replace(re, `${begin}\n${html}\n${end}`)
- fs.writeFileSync(readmePath, next)
-}
-
-const entries = JSON.parse(fs.readFileSync(dataPath, 'utf8'))
-
-async function main () {
- const html = await renderHtml(entries)
- patchReadme(html)
- fs.writeFileSync(path.join(outDir, 'used-by.swig'), transformUsedBy(html))
-}
-
-main().catch((err) => {
- console.error(err)
- process.exit(1)
-})
diff --git a/data/used-by.json b/data/used-by.json
deleted file mode 100644
index eb73ae271..000000000
--- a/data/used-by.json
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- { "name": "Eleventy", "url": "https://www.11ty.dev/" },
- { "name": "GitHub Docs", "url": "https://docs.github.com/" },
- { "name": "Kibana", "url": "https://www.elastic.co/kibana" },
- {
- "name": "Power Pages, Azure API Management developer portal",
- "url": "https://learn.microsoft.com/en-us/power-pages/"
- },
- {
- "name": "Shopify CLI, Checkout Blocks",
- "url": "https://www.shopify.com/"
- },
- { "name": "Directus", "url": "https://directus.io/" },
- {
- "name": "Builder.io, Mitosis",
- "url": "https://www.builder.io/"
- },
- { "name": "Pattern Lab", "url": "https://patternlab.io/" },
- { "name": "Rock RMS", "url": "https://www.rockrms.com/" },
- { "name": "WISMOlabs", "url": "https://wismolabs.com/" },
- { "name": "Dropkiq", "url": "https://www.dropkiq.com/" },
- {
- "name": "Freshet",
- "url": "https://chromewebstore.google.com/detail/freshet/mpclplhdencffbilobpcapccnihpelcg",
- "logo": "https://raw.githubusercontent.com/MattAltermatt/freshet/main/public/icon-128.png"
- }
-]
diff --git a/docs/package.json b/docs/package.json
index 28252b62e..76474f5ea 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -6,7 +6,7 @@
"version": "7.3.0"
},
"scripts": {
- "prebuild": "npm --prefix .. run build:contributors && npm --prefix .. run build:used-by",
+ "prebuild": "npm --prefix .. run build:contributors",
"build": "hexo generate",
"start": "hexo serve",
"lint": "eslint .",
diff --git a/docs/themes/navy/languages/en.yml b/docs/themes/navy/languages/en.yml
index c18fd497a..27116132b 100644
--- a/docs/themes/navy/languages/en.yml
+++ b/docs/themes/navy/languages/en.yml
@@ -16,7 +16,7 @@ index:
description: 'Organizations and individuals who sponsor LiquidJS. Thank you!'
used_by:
title: Used by
- description: 'Products and projects running on LiquidJS. Open a PR to add yours.'
+ description: 'Products and projects running on LiquidJS. Open a PR to add yours.'
playground:
title: Playground
diff --git a/package.json b/package.json
index 2e1251bca..5329ecb99 100644
--- a/package.json
+++ b/package.json
@@ -29,14 +29,13 @@
"build:min": "BUNDLES=min rollup -c rollup.config.mjs",
"build:umd": "BUNDLES=umd rollup -c rollup.config.mjs",
"build:charmap": "./bin/character-gen.js > src/util/character.ts",
- "build:docs": "run-s build:docs-liquid build:contributors build:used-by build:apidoc build:changelog build:docs-hexo",
+ "build:docs": "run-s build:docs-liquid build:contributors build:apidoc build:changelog build:docs-hexo",
"build:docs-liquid": "cross-env BUNDLES=min rollup -c rollup.config.mjs && shx cp dist/liquid.browser.min.js docs/themes/navy/source/js/",
"build:contributors": "node bin/build-contributors.js",
- "build:used-by": "node bin/build-used-by.js",
"build:apidoc": "shx rm -rf docs/source/api && typedoc --plugin typedoc-plugin-missing-exports ./src --gitRevision master --out docs/source/api",
"build:changelog": "node bin/build-changelog.js",
"build:docs-hexo": "cd docs && npm ci && npm run build && shx cp CNAME public/",
- "docs:dev": "run-s build:docs-liquid build:contributors build:used-by docs:serve",
+ "docs:dev": "run-s build:docs-liquid build:contributors docs:serve",
"docs:serve": "cd docs && npm run start"
},
"bin": {