Merge seeded platform links on container upgrades
This commit is contained in:
@@ -23,4 +23,83 @@ if [ -d "$SEED_DIR" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Merge newly added seeded platform links into existing admin content on upgrades
|
||||
# without overwriting user-edited values already present in the live volume.
|
||||
merge_seed_platform_links() {
|
||||
target_file="$1"
|
||||
seed_file="$2"
|
||||
|
||||
[ -f "$target_file" ] || return 0
|
||||
[ -f "$seed_file" ] || return 0
|
||||
|
||||
node - "$target_file" "$seed_file" <<'NODE'
|
||||
const fs = require('fs')
|
||||
|
||||
const [targetFile, seedFile] = process.argv.slice(2)
|
||||
|
||||
function readJson(file) {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8'))
|
||||
}
|
||||
|
||||
function normalizeLinks(value) {
|
||||
return Array.isArray(value) ? value.filter(item => item && typeof item === 'object') : []
|
||||
}
|
||||
|
||||
const target = readJson(targetFile)
|
||||
const seed = readJson(seedFile)
|
||||
|
||||
if (!target.siteContent || !seed.siteContent) process.exit(0)
|
||||
|
||||
const targetLinks = normalizeLinks(target.siteContent.customLinks)
|
||||
const seedLinks = normalizeLinks(seed.siteContent.customLinks)
|
||||
|
||||
let changed = false
|
||||
|
||||
for (const seedLink of seedLinks) {
|
||||
if (seedLink.placement !== 'platforms' || !seedLink.id || !seedLink.label || !seedLink.url) continue
|
||||
|
||||
const existingIndex = targetLinks.findIndex(link => link.id === seedLink.id)
|
||||
if (existingIndex === -1) {
|
||||
targetLinks.push(seedLink)
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
|
||||
const existing = targetLinks[existingIndex]
|
||||
const merged = { ...existing }
|
||||
|
||||
if (!merged.imageUrl && seedLink.imageUrl) {
|
||||
merged.imageUrl = seedLink.imageUrl
|
||||
changed = true
|
||||
}
|
||||
|
||||
if (!merged.placement && seedLink.placement) {
|
||||
merged.placement = seedLink.placement
|
||||
changed = true
|
||||
}
|
||||
|
||||
if (!merged.label && seedLink.label) {
|
||||
merged.label = seedLink.label
|
||||
changed = true
|
||||
}
|
||||
|
||||
if (!merged.url && seedLink.url) {
|
||||
merged.url = seedLink.url
|
||||
changed = true
|
||||
}
|
||||
|
||||
targetLinks[existingIndex] = merged
|
||||
}
|
||||
|
||||
if (!changed) process.exit(0)
|
||||
|
||||
target.siteContent.customLinks = targetLinks
|
||||
fs.writeFileSync(targetFile, `${JSON.stringify(target, null, 2)}\n`)
|
||||
console.log(`[siteforge] Merged seeded platform links into ${targetFile}`)
|
||||
NODE
|
||||
}
|
||||
|
||||
merge_seed_platform_links "$DATA_DIR/admin-content.json" "$SEED_DIR/admin-content.json"
|
||||
merge_seed_platform_links "$DATA_DIR/admin-content-draft.json" "$SEED_DIR/admin-content-draft.json"
|
||||
|
||||
exec node server.js
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="184" height="48" viewBox="0 0 184 48">
|
||||
<rect width="184" height="48" rx="6" fill="#1877F2"/>
|
||||
<g transform="translate(11,11)">
|
||||
<circle cx="13" cy="13" r="12" fill="rgba(255,255,255,0.16)"/>
|
||||
<path fill="#ffffff" d="M17.755 13.037C17.755 10.385 15.617 8.237 12.98 8.237c-2.638 0-4.776 2.148-4.776 4.8 0 2.396 1.744 4.383 4.028 4.743v-3.36H11.01v-1.383h1.222v-1.054c0-1.215.719-1.887 1.82-1.887.527 0 1.078.094 1.078.094v1.193h-.608c-.598 0-.784.373-.784.755v.899h1.334l-.213 1.383h-1.121v3.36c2.284-.36 4.017-2.347 4.017-4.743z"/>
|
||||
</g>
|
||||
<text font-family="Helvetica Neue, Helvetica, Arial, sans-serif" fill="rgba(255,255,255,0.82)" font-size="9.5" x="52" y="19">Follow on</text>
|
||||
<text font-family="Helvetica Neue, Helvetica, Arial, sans-serif" fill="#ffffff" font-size="16" font-weight="bold" x="52" y="36">Facebook</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 891 B |
+2
-4
@@ -3,7 +3,6 @@ import { Link, NavLink, Routes, Route, useLocation, useNavigate, useParams } fro
|
||||
import AdminPage from './AdminPage'
|
||||
import QASection from './components/QASection'
|
||||
import ContactForm from './components/ContactForm'
|
||||
import { FacebookIcon, SpotifyIcon } from './icons'
|
||||
import type { SiteContent, ArchivedSeries } from './content'
|
||||
import { DEFAULTS } from './content'
|
||||
import './App.css'
|
||||
@@ -496,9 +495,8 @@ function PlatformButtons({ content }: { content: SiteContent }) {
|
||||
<a href={amazonUrl} target="_blank" rel="noreferrer" className="platform-btn platform-btn-image">
|
||||
<img src="/images/listen-on-amazon-music.svg" alt="Listen on Amazon Music" className="platform-badge" />
|
||||
</a>
|
||||
<a href={facebookUrl} target="_blank" rel="noreferrer" className="platform-btn facebook-btn">
|
||||
<FacebookIcon />
|
||||
Facebook
|
||||
<a href={facebookUrl} target="_blank" rel="noreferrer" className="platform-btn platform-btn-image">
|
||||
<img src="/images/follow-on-facebook.svg" alt="Follow on Facebook" className="platform-badge" />
|
||||
</a>
|
||||
{(content.customLinks ?? []).filter(l => l.placement === 'platforms').map(l => (
|
||||
<a
|
||||
|
||||
Reference in New Issue
Block a user