feat: give releases and tracks their own pages
Albums were three hardcoded cards. An album is a chrnx_release term now, with cover, status and listening links; its archive is the album page with an ordered tracklist. A song is a post carrying lyrics and notes, its track number, and the audio. The player is a native audio element, no library and no JavaScript. Platform icons render only when a URL exists, so nothing points at a service the release is not on yet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
13 files changed
+867
-16
No files matched your search
@@ -0,0 +1,50 @@
|
||||
( function () {
|
||||
'use strict';
|
||||
|
||||
function initialize( doc, media ) {
|
||||
const input = doc.querySelector( '[data-chrnx-release-cover]' );
|
||||
const button = doc.querySelector( '[data-chrnx-release-cover-pick]' );
|
||||
const preview = doc.querySelector( '[data-chrnx-release-cover-preview]' );
|
||||
if ( ! input || ! button || ! preview || typeof media !== 'function' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let frame = null;
|
||||
button.addEventListener( 'click', function () {
|
||||
if ( ! frame ) {
|
||||
frame = media( {
|
||||
title: button.textContent,
|
||||
library: { type: 'image' },
|
||||
multiple: false,
|
||||
} );
|
||||
frame.on( 'select', function () {
|
||||
const attachment = frame.state().get( 'selection' ).first().toJSON();
|
||||
input.value = attachment.id;
|
||||
const source = attachment.sizes?.medium?.url || attachment.url;
|
||||
preview.innerHTML = '';
|
||||
const image = doc.createElement( 'img' );
|
||||
image.src = source;
|
||||
image.alt = attachment.alt || '';
|
||||
image.style.maxWidth = '240px';
|
||||
image.style.height = 'auto';
|
||||
preview.append( image );
|
||||
} );
|
||||
}
|
||||
frame.open();
|
||||
} );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( typeof module !== 'undefined' && module.exports ) {
|
||||
module.exports = { initialize };
|
||||
} else if ( typeof document !== 'undefined' ) {
|
||||
const start = function () {
|
||||
initialize( document, window.wp && window.wp.media );
|
||||
};
|
||||
if ( document.readyState === 'loading' ) {
|
||||
document.addEventListener( 'DOMContentLoaded', start, { once: true } );
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
}
|
||||
} )();
|
||||
Reference in new issue
Block a user