Stage Happy Beta announcement and its approved artwork without publishing
This commit is contained in:
parent
799cdf3324
commit
95dfa7e0a4
7 changed files with 18 additions and 9 deletions
|
|
@ -4,6 +4,8 @@ import {randomUUID} from 'node:crypto';
|
|||
import {readFile} from 'node:fs/promises';
|
||||
import {json} from './game-link.mjs';
|
||||
import {OFFICIAL_ACCOUNT} from './official-account.mjs';
|
||||
export const BETA_NEWS_SOURCE='announcement:beta-1-0-0-0';
|
||||
export const BETA_NEWS_ARTWORK='assets/happy-beta-launch.png';
|
||||
export const NEWS_CATEGORIES={world:'World',news:'NEWS',maintenance:'Maintenance',changelogs:'Changelogs',events:'Events',community:'Community',unis_blog:"Uni’s Blog"};
|
||||
export function publicNewsExcerpt(body){return String(body||'').replace(/!\[[^\]]*\]\([^)]*\)/g,'').replace(/\[([^\]]+)\]\([^)]*\)/g,'$1').replace(/^\s*#{1,6}\s+/gm,'').replace(/[*_`]/g,'').replace(/\s+/g,' ').trim().slice(0,220);}
|
||||
export async function initializeNews(db){
|
||||
|
|
@ -28,11 +30,11 @@ export function createPublicNews(db){return async request=>{
|
|||
try{return json(await nativeForumFeed(page));}catch{return json({message:'Forum updates are temporarily unavailable.'},503);}
|
||||
}
|
||||
const match=url.pathname.match(/^\/api\/news\/([0-9a-f-]{36})$/i);
|
||||
if(match){const post=await db.prepare("SELECT p.id,p.title,p.body,p.category,p.published_at,c.label,c.artwork,COALESCE(a.display_name,a.username,'DuneRealms') AS author_name FROM website_posts p JOIN website_post_categories c ON c.category_key=p.category LEFT JOIN site_accounts a ON a.id=p.author_id WHERE p.id=? AND p.status='published' AND p.published_at<=?").bind(match[1],Date.now()).first();return post?json({post:(await forumLinks(db,[{...post,publisher:GAZETTE_NAME}]))[0]}):json({message:'Post not found'},404);}
|
||||
if(match){const post=await db.prepare("SELECT p.id,p.title,p.body,p.category,p.published_at,c.label,CASE WHEN p.source_key='announcement:beta-1-0-0-0' THEN 'assets/happy-beta-launch.png' ELSE c.artwork END AS artwork,COALESCE(a.display_name,a.username,'DuneRealms') AS author_name FROM website_posts p JOIN website_post_categories c ON c.category_key=p.category LEFT JOIN site_accounts a ON a.id=p.author_id WHERE p.id=? AND p.status='published' AND p.published_at<=?").bind(match[1],Date.now()).first();return post?json({post:(await forumLinks(db,[{...post,publisher:GAZETTE_NAME}]))[0]}):json({message:'Post not found'},404);}
|
||||
if(url.pathname!=='/api/news')return json({message:'Not found'},404);
|
||||
const page=Number(url.searchParams.get('page')||1),archive=url.searchParams.get('surface')==='archive',size=archive?25:5;
|
||||
if(!Number.isSafeInteger(page)||page<1||page>1000000)return json({message:'Invalid page'},400);
|
||||
const count=await db.prepare("SELECT COUNT(*) AS count FROM website_posts WHERE status='published' AND published_at<=?").bind(Date.now()).first();
|
||||
const {results}=await db.prepare("SELECT p.id,p.title,p.body,p.category,p.published_at,c.label,c.artwork,COALESCE(a.display_name,a.username,'DuneRealms') AS author_name FROM website_posts p JOIN website_post_categories c ON c.category_key=p.category LEFT JOIN site_accounts a ON a.id=p.author_id WHERE p.status='published' AND p.published_at<=? ORDER BY p.published_at DESC,p.id DESC LIMIT ? OFFSET ?").bind(Date.now(),size,(page-1)*size).all();
|
||||
const {results}=await db.prepare("SELECT p.id,p.title,p.body,p.category,p.published_at,c.label,CASE WHEN p.source_key='announcement:beta-1-0-0-0' THEN 'assets/happy-beta-launch.png' ELSE c.artwork END AS artwork,COALESCE(a.display_name,a.username,'DuneRealms') AS author_name FROM website_posts p JOIN website_post_categories c ON c.category_key=p.category LEFT JOIN site_accounts a ON a.id=p.author_id WHERE p.status='published' AND p.published_at<=? ORDER BY p.published_at DESC,p.id DESC LIMIT ? OFFSET ?").bind(Date.now(),size,(page-1)*size).all();
|
||||
return json({posts:await forumLinks(db,results.map(p=>({...p,publisher:GAZETTE_NAME,body:publicNewsExcerpt(p.body)}))),page,pages:Math.max(1,Math.ceil(Number(count.count)/size)),total:Number(count.count)});
|
||||
};}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {renderNewsBody} from './news-format.mjs';
|
||||
import {forumLinks,NEWS_CATEGORIES} from './news.mjs';
|
||||
import {forumLinks,NEWS_CATEGORIES,BETA_NEWS_SOURCE,BETA_NEWS_ARTWORK} from './news.mjs';
|
||||
import {SHARED_HEADER,SHARED_HEAD} from '../scripts/portal-navigation.mjs';
|
||||
const base='https://www.dunerealms.com';
|
||||
const esc=v=>String(v??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||||
|
|
@ -13,7 +13,7 @@ const pages={
|
|||
'/staff.html':['DuneRealms Staff & Contributors','Meet the DuneRealms community staff and project contributors.']
|
||||
};
|
||||
export const newsPath=p=>'/news/'+p.title.toLowerCase().normalize('NFKD').replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,75)+'-'+p.id;
|
||||
const published="SELECT p.id,p.title,p.body,p.category,p.published_at,p.updated_at,COALESCE(a.display_name,a.username,'DuneRealms') author_name FROM website_posts p LEFT JOIN site_accounts a ON a.id=p.author_id WHERE p.status='published' AND p.published_at<=?";
|
||||
const published="SELECT p.id,p.source_key,p.title,p.body,p.category,p.published_at,p.updated_at,COALESCE(a.display_name,a.username,'DuneRealms') author_name FROM website_posts p LEFT JOIN site_accounts a ON a.id=p.author_id WHERE p.status='published' AND p.published_at<=?";
|
||||
const ld=data=>'<script type="application/ld+json">'+JSON.stringify(data).replaceAll('<','\\u003c')+'</script>';
|
||||
function metadata(html,{title,description,canonical,type='website',image=base+'/assets/dunerealms-season-logo-v2.png',structured}){
|
||||
html=html.replace(/<title>[\s\S]*?<\/title>/i,'').replace(/<meta\b(?=[^>]*(?:name=["'](?:description|robots|twitter:[^"']+)["']|property=["']og:[^"']+["']))[^>]*>/gi,'').replace(/<link\b(?=[^>]*rel=["']canonical["'])[^>]*>/gi,'');
|
||||
|
|
@ -37,7 +37,7 @@ export function createSearchVisibility(db){
|
|||
const p=await db.prepare(published+' AND p.id=?').bind(Date.now(),id).first();if(!p)return new Response('News post not found',{status:404,headers:{'X-Robots-Tag':'noindex'}});
|
||||
const path=newsPath(p);if(legacy||u.pathname!==path)return Response.redirect(base+path,301);
|
||||
const description=p.body.replace(/\s+/g,' ').slice(0,160),date=new Date(Number(p.published_at)).toISOString();
|
||||
const art='/assets/news-'+(['world','news','maintenance','changelogs','events','community'].includes(p.category)?p.category:'news')+'.webp';
|
||||
const art=p.source_key===BETA_NEWS_SOURCE?'/'+BETA_NEWS_ARTWORK:'/assets/news-'+(['world','news','maintenance','changelogs','events','community'].includes(p.category)?p.category:'news')+'.webp';
|
||||
const linked=(await forumLinks(db,[p]))[0],byline='<p class="dispatch-byline">Written by '+esc(p.author_name)+'</p>',discussion=linked.forum_url?'<p><a class="dispatch-read-more" href="'+esc(linked.forum_url)+'">Go to forum post →</a></p>':'';
|
||||
let html='<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="/styles.css"><link rel="stylesheet" href="/home-news.css?v=article-20261102">'+SHARED_HEAD+'</head><body class="home-news news-article-page">'+SHARED_HEADER+'<main id="main"><article id="news-full-post" class="dispatch-full"><a class="article-back" href="/news-archive.html">← News archive</a><div class="article-heading"><div><div class="article-meta"><span class="article-category">'+esc(NEWS_CATEGORIES[p.category]||NEWS_CATEGORIES.news)+'</span><time datetime="'+date+'">'+esc(new Date(Number(p.published_at)).toLocaleDateString('en-GB',{dateStyle:'long'}))+'</time></div><h1>'+esc(p.title)+'</h1>'+byline+'</div><img src="'+art+'" alt="Imperial dispatch artwork" width="360" height="240"></div><div class="dispatch-full-body article-body">'+renderNewsBody(p.body)+'</div>'+discussion+'</article></main><footer><a href="/">DuneRealms</a> · <a href="/wiki.html">Disclaimer & contact</a></footer></body></html>';
|
||||
html=metadata(html,{title:p.title+' | DuneRealms',description,canonical:base+path,type:'article',structured:{'@context':'https://schema.org','@type':'NewsArticle',headline:p.title,datePublished:date,dateModified:new Date(Number(p.updated_at||p.published_at)).toISOString(),mainEntityOfPage:base+path,image:[base+'/assets/dunerealms-season-logo-v2.png'],publisher:{'@type':'Organization',name:'DuneRealms',url:base}}});
|
||||
|
|
|
|||
7
website/scripts/beta-launch-announcement.staged.json
Normal file
7
website/scripts/beta-launch-announcement.staged.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "beta-1-0-0-0",
|
||||
"publishedAt": null,
|
||||
"title": "Happy Beta! · DuneRealms Beta 1.0.0.0",
|
||||
"body": "The caravan endures. Welcome to DuneRealms Beta 1.0.0.0!\n\nThank you to our Alpha testers and the community that brought our worlds to life. The Beta era is now open. The realm’s worlds and economy remain intact as a new political chapter begins.\n\nYour House. Your destiny. Write your chapter.",
|
||||
"artwork": "assets/happy-beta-launch.png"
|
||||
}
|
||||
BIN
website/web/assets/happy-beta-launch.png
Normal file
BIN
website/web/assets/happy-beta-launch.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
|
|
@ -1,7 +1,7 @@
|
|||
const newsEl=(tag,text)=>{const el=document.createElement(tag);if(text!==undefined)el.textContent=text;return el;};
|
||||
const newsDate=n=>new Date(Number(n)).toLocaleDateString(undefined,{year:'numeric',month:'short',day:'numeric'});
|
||||
async function newsFetch(path){const response=await fetch(path,{cache:'no-store'});if(!response.ok)throw Error('Updates are temporarily unavailable. Please try again later.');return response.json();}
|
||||
function newsCard(post,forum=false){const card=newsEl('article');card.className='dispatch-card';const image=newsEl('img');image.src=forum?'assets/nav-boards-full-v2.webp':'assets/nav-discord-full-v2.webp';image.alt='';image.loading='lazy';image.width=1672;image.height=941;const content=newsEl('div');content.className='dispatch-copy';content.append(newsEl('span',forum?'COMMUNITY':post.label),newsEl('small',newsDate(forum?post.last_activity_at:post.published_at)));const title=newsEl('h3'),link=newsEl('a',post.title);link.title=post.title;link.href=forum?post.url:'news-archive.html?post='+post.id;title.append(link);content.append(title,newsEl('p',forum?post.excerpt:post.body.split(/\n\s*\n/)[0]));if(!forum&&post.publisher)content.append(newsEl('small',post.publisher));const more=newsEl('a',forum?'Read discussion →':'Read more →');more.className='dispatch-read-more';more.href=link.href;content.append(more);card.append(image,content);return card;}
|
||||
function newsCard(post,forum=false){const card=newsEl('article');card.className='dispatch-card';const image=newsEl('img');image.src=forum?'assets/nav-boards-full-v2.webp':post.artwork==='assets/happy-beta-launch.png'?'assets/happy-beta-launch.png':'assets/nav-discord-full-v2.webp';image.alt='';image.loading='lazy';image.width=1672;image.height=941;const content=newsEl('div');content.className='dispatch-copy';content.append(newsEl('span',forum?'COMMUNITY':post.label),newsEl('small',newsDate(forum?post.last_activity_at:post.published_at)));const title=newsEl('h3'),link=newsEl('a',post.title);link.title=post.title;link.href=forum?post.url:'news-archive.html?post='+post.id;title.append(link);content.append(title,newsEl('p',forum?post.excerpt:post.body.split(/\n\s*\n/)[0]));if(!forum&&post.publisher)content.append(newsEl('small',post.publisher));const more=newsEl('a',forum?'Read discussion →':'Read more →');more.className='dispatch-read-more';more.href=link.href;content.append(more);card.append(image,content);return card;}
|
||||
function newsModule(root,kind){let page=1,generation=0;const archive=root.dataset.archive==='true',grid=newsEl('div');grid.className='dispatch-grid';grid.setAttribute('aria-live','polite');const controls=newsEl('nav');controls.className='dispatch-pagination';controls.setAttribute('aria-label',kind==='forum'?'Latest forum posts pages':'News pages');const prev=newsEl('button','← Previous'),state=newsEl('span'),next=newsEl('button','Next →');prev.type=next.type='button';controls.append(prev,state,next);root.append(grid,controls);
|
||||
async function load(){const token=++generation;prev.disabled=next.disabled=true;state.textContent='Loading…';try{const data=await newsFetch(kind==='forum'?'/api/home/forum?page='+page:'/api/news?'+new URLSearchParams({page,surface:archive?'archive':'home'}));if(token!==generation)return;root.querySelector('[data-server-news]')?.remove();grid.replaceChildren();for(const post of data.posts)grid.append(newsCard(post,kind==='forum'));if(!data.posts.length)grid.append(newsEl('p',kind==='forum'?'No public discussions yet. Start one in the forums.':'No published news yet. Updates will appear here when released.'));state.textContent='Page '+page+' of '+Math.max(1,data.pages);prev.disabled=page<=1;next.disabled=page>=data.pages;}catch(error){if(token===generation){grid.replaceChildren(newsEl('p',error.message));state.textContent='Unavailable';}}}
|
||||
prev.onclick=()=>{page--;load();};next.onclick=()=>{page++;load();};root.addEventListener('keydown',event=>{if(event.target instanceof HTMLInputElement||event.target instanceof HTMLTextAreaElement)return;if(event.key==='ArrowLeft'&&!prev.disabled){event.preventDefault();prev.click();}if(event.key==='ArrowRight'&&!next.disabled){event.preventDefault();next.click();}});load();
|
||||
|
|
@ -18,7 +18,7 @@ if(fullPost&&postId){
|
|||
const head=newsEl('div');head.className='article-heading';const copy=newsEl('div');
|
||||
const category=newsEl('span',post.label);category.className='article-category';const date=newsEl('time',newsDate(post.published_at));date.dateTime=new Date(Number(post.published_at)).toISOString();
|
||||
const meta=newsEl('div');meta.className='article-meta';meta.append(category,date);meta.append(newsEl('span','Written by '+(post.author_name||'DuneRealms')));if(post.publisher)meta.append(newsEl('span',post.publisher));copy.append(meta,newsEl('h1',post.title));
|
||||
const image=newsEl('img');const artKeys=['world','news','maintenance','changelogs','events','community'];image.src='assets/news-'+(artKeys.includes(post.category_key||post.category)?(post.category_key||post.category):'news')+'.webp';image.alt='Imperial dispatch artwork';image.width=360;image.height=240;head.append(copy,image);
|
||||
const image=newsEl('img');const artKeys=['world','news','maintenance','changelogs','events','community'];image.src=post.artwork==='assets/happy-beta-launch.png'?'assets/happy-beta-launch.png':'assets/news-'+(artKeys.includes(post.category_key||post.category)?(post.category_key||post.category):'news')+'.webp';image.alt='Imperial dispatch artwork';image.width=360;image.height=240;head.append(copy,image);
|
||||
const body=newsEl('div');body.className='dispatch-full-body';formatNewsBody(body,post.body);
|
||||
const foot=newsEl('div');foot.className='article-actions';const all=newsEl('a','Browse all news →');all.href='news-archive.html';all.className='dispatch-read-more';foot.append(all);if(post.forum_url){const forum=newsEl('a','Go to forum post →');forum.href=post.forum_url;forum.className='dispatch-read-more';foot.append(forum);}
|
||||
fullPost.append(back,head,body,foot);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
(()=>{
|
||||
const el=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n;},dateFormatter=null;const date=value=>new Date(Number(value)).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'});
|
||||
let page=0,posts=[],pageCount=1;let requestSerial=0;async function loadNews(){document.getElementById("news-prev").disabled=document.getElementById("news-next").disabled=true;const serial=++requestSerial;try{const r=await fetch('/api/news?page='+(page+1),{cache:'no-store'});if(!r.ok)throw Error();const d=await r.json();if(serial!==requestSerial)return;posts=d.posts;pageCount=Math.max(1,d.pages);renderNews();}catch{document.getElementById('news-grid').replaceChildren(el('p','News is temporarily unavailable. Please try again later.'));}}function renderNews(){const grid=document.getElementById('news-grid');grid.replaceChildren();for(const p of posts){const card=el('article');card.className='news-card';const img=el('img');img.src='/assets/news-'+(['world','news','maintenance','changelogs','events','community'].includes(p.category)?p.category:'news')+'.webp';img.alt='';const copy=el('div');copy.className='card-copy';const tag=el('span',p.label);tag.className='tag';const time=el('time',date(p.published_at)),heading=el('h3',p.title),excerpt=el('p',p.body.replace(/[#*]/g,'').slice(0,125)+(p.body.length>125?'…':'')),by=el('div','Written by '+p.author_name);by.className='byline';const actions=el('div');actions.className='card-links';const read=el('a','Read article →');read.href='news-archive.html?post='+encodeURIComponent(p.id);if(p.forum_url){const forum=el('a','Forum topic ↗');forum.href=p.forum_url;actions.append(read,forum);}else actions.append(read);copy.append(tag,time,heading,excerpt,by,actions);card.append(img,copy);grid.append(card);}document.getElementById('news-page').textContent='Page '+(page+1)+' of '+Math.max(1,pageCount);document.getElementById('news-prev').disabled=page===0;document.getElementById('news-next').disabled=page+1>=pageCount;}document.getElementById('news-prev').onclick=()=>{page--;loadNews();};document.getElementById('news-next').onclick=()=>{page++;loadNews();};loadNews();
|
||||
let page=0,posts=[],pageCount=1;let requestSerial=0;async function loadNews(){document.getElementById("news-prev").disabled=document.getElementById("news-next").disabled=true;const serial=++requestSerial;try{const r=await fetch('/api/news?page='+(page+1),{cache:'no-store'});if(!r.ok)throw Error();const d=await r.json();if(serial!==requestSerial)return;posts=d.posts;pageCount=Math.max(1,d.pages);renderNews();}catch{document.getElementById('news-grid').replaceChildren(el('p','News is temporarily unavailable. Please try again later.'));}}function renderNews(){const grid=document.getElementById('news-grid');grid.replaceChildren();for(const p of posts){const card=el('article');card.className='news-card';const img=el('img');img.src=p.artwork==='assets/happy-beta-launch.png'?'/assets/happy-beta-launch.png':'/assets/news-'+(['world','news','maintenance','changelogs','events','community'].includes(p.category)?p.category:'news')+'.webp';img.alt='';const copy=el('div');copy.className='card-copy';const tag=el('span',p.label);tag.className='tag';const time=el('time',date(p.published_at)),heading=el('h3',p.title),excerpt=el('p',p.body.replace(/[#*]/g,'').slice(0,125)+(p.body.length>125?'…':'')),by=el('div','Written by '+p.author_name);by.className='byline';const actions=el('div');actions.className='card-links';const read=el('a','Read article →');read.href='news-archive.html?post='+encodeURIComponent(p.id);if(p.forum_url){const forum=el('a','Forum topic ↗');forum.href=p.forum_url;actions.append(read,forum);}else actions.append(read);copy.append(tag,time,heading,excerpt,by,actions);card.append(img,copy);grid.append(card);}document.getElementById('news-page').textContent='Page '+(page+1)+' of '+Math.max(1,pageCount);document.getElementById('news-prev').disabled=page===0;document.getElementById('news-next').disabled=page+1>=pageCount;}document.getElementById('news-prev').onclick=()=>{page--;loadNews();};document.getElementById('news-next').onclick=()=>{page++;loadNews();};loadNews();
|
||||
function record(b,appeal=false,list=false){const card=el('article');card.className='record-card';const art=el('div');art.className='record-art';const img=el('img');img.src=appeal?'/assets/portal-appeal-ledger-v1.png':'/assets/portal-ban-gate-v1.png';img.alt=appeal?'Imperial petition ledger':'Imperial fortress gate';const status=el('strong',(appeal?b.appealStatus:b.status)||'Recorded');status.className='stamp '+(b.appealStatus||'');if(appeal&&['approved','denied'].includes(b.appealStatus)){status.classList.add('wax-stamp');const wax=el('img');wax.src='/assets/appeal-'+b.appealStatus+'-wax-v1.png';wax.alt='';status.append(wax);}art.append(img,status);const copy=el('div');copy.className='card-copy';copy.append(el('h3',b.player||'Unknown player'));const fields=el('dl');for(const[k,v]of [['Reason',b.reason],['Issued by',b.issuedBy],['Scope',b.scope],['Duration',b.expires==='forever'?'Permanent':b.expires]])fields.append(el('dt',k),el('dd',v||'Recorded'));copy.append(fields);const action=el('a',b.status==='Unbanned'?'Resolved record':b.appealStatus==='pending'?'View pending appeal →':'Appeal ban →');action.className='record-action';action.href=b.status==='Unbanned'?'https://cp.dunerealms.com/?banId='+encodeURIComponent(b.id)+'#bans':'https://support.dunerealms.com/appeal.php?ban_id='+encodeURIComponent(b.id);if(appeal){action.textContent='View decision →';action.href='https://cp.dunerealms.com/?banId='+encodeURIComponent(b.id)+'#bans';}copy.append(action);card.append(art,copy);return card;}
|
||||
fetch('/api/public/ban-list',{cache:'no-store'}).then(r=>r.json()).then(data=>{const rows=data.bans||[];fetch('/api/public/bans',{cache:'no-store'}).then(r=>r.json()).then(d=>{for(const b of d.bans.slice(0,3))document.getElementById('latest-bans').append(record({id:b.id,player:b.player_name,issuedBy:b.banned_by,reason:b.reason,scope:b.scope,expires:b.expires_text,status:'Active'}));}).catch(()=>{});const active=rows.filter(b=>b.status!=='Unbanned');const resolved=rows.filter(b=>b.status==='Unbanned');for(const b of [...active.slice(0,3),...resolved.slice(0,3)])document.getElementById('ban-list').append(record(b,false,true));});fetch('/api/public/appeals',{cache:'no-store'}).then(r=>r.json()).then(data=>{for(const b of (data.bans||[]).slice(0,3))document.getElementById('latest-appeals').append(record(b,true));});
|
||||
// Account-ban examples remain separate from real server enforcement records.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
for(const [i,post]of data.posts.slice(0,3).entries()){
|
||||
const card=node('article',undefined,'news-card'+(!i?' featured':'')),href='https://www.dunerealms.com/news-archive.html?post='+encodeURIComponent(post.id),art=node('a',undefined,'news-art'),image=node('img');
|
||||
// Reuse the editorial artwork register; never load arbitrary author URLs.
|
||||
const approved=['world','news','maintenance','changelogs','events','community'];image.src='/assets/news-'+(approved.includes(post.category)?post.category:'news')+'.webp';image.alt='';image.loading='lazy';art.href=href;art.setAttribute('aria-label',post.title);art.append(image);
|
||||
const approved=['world','news','maintenance','changelogs','events','community'];image.src=post.artwork==='assets/happy-beta-launch.png'?'/assets/happy-beta-launch.png':'/assets/news-'+(approved.includes(post.category)?post.category:'news')+'.webp';image.alt='';image.loading='lazy';art.href=href;art.setAttribute('aria-label',post.title);art.append(image);
|
||||
const copy=node('div',undefined,'news-copy'),meta=node('div',undefined,'news-meta');meta.append(node('span',post.label||'News'));if(Number.isFinite(Number(post.published_at)))meta.append(node('time',date(post.published_at)));const heading=node('h3'),title=node('a',post.title);title.href=href;heading.append(title);const read=node('a','Read dispatch →','text-link');read.href=href;copy.append(meta,heading,node('p',excerpt(post.body)+'…'),read);card.append(art,copy);host.append(card);
|
||||
}
|
||||
if(!host.children.length)host.append(node('p','The next chapter is on its way. Published news will appear here.','news-loading'));
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff