change: dev build & publish falseの投稿に目印をつけるなどをした

This commit is contained in:
moris 2024-12-15 20:16:48 +09:00
parent d22b5cfc6f
commit 57efc611cd
3 changed files with 17 additions and 16 deletions

View File

@ -10,7 +10,6 @@ async function Metadatas() {
const cache_dir = '/tmp/day.moris.blog/'; const cache_dir = '/tmp/day.moris.blog/';
const cache_file = `${cache_dir}metadata.json`; const cache_file = `${cache_dir}metadata.json`;
async function build() { async function build() {
const posts = await Posts(); const posts = await Posts();
@ -20,9 +19,11 @@ async function Metadatas() {
return {postId, metadata} return {postId, metadata}
})) }))
const sorted = metadataList.sort((a,b)=>{ const sorted = metadataList
.sort((a,b)=>{
return b.metadata.date.getTime() - a.metadata.date.getTime() return b.metadata.date.getTime() - a.metadata.date.getTime()
}) })
.filter((m)=> dev||m.metadata.published)
return sorted return sorted
} }

View File

@ -7,13 +7,11 @@
<div class='contain'> <div class='contain'>
<div class="posts"> <div class="posts">
{#each data.posts as post} {#each data.posts as post}
{#if post.metadata.published} <div class="post" class:published={!post.metadata.published}>
<div class="post">
<a style='text-decoration: none;' href="../post/{post.postId}" tabindex="0"> <a style='text-decoration: none;' href="../post/{post.postId}" tabindex="0">
<Postgrid id={post.postId} {...post.metadata}></Postgrid> <Postgrid id={post.postId} {...post.metadata}></Postgrid>
</a> </a>
</div> </div>
{/if}
{/each} {/each}
{#if data.posts.length%4} {#if data.posts.length%4}
{#each Array(4-data.posts.length%4) as i} {#each Array(4-data.posts.length%4) as i}
@ -48,6 +46,10 @@
border-radius: 8px; border-radius: 8px;
overflow: hidden; overflow: hidden;
box-shadow: 0 0 6px #0001; box-shadow: 0 0 6px #0001;
&.published {
border: solid red 3px;
}
} }
.paging { .paging {

View File

@ -18,17 +18,15 @@ export async function GET() {
let meta = post.metadata let meta = post.metadata
let link = `https://${PUBLIC_HOSTNAME}/blog/post/${path.basename(post.postId, '.md')}` let link = `https://${PUBLIC_HOSTNAME}/blog/post/${path.basename(post.postId, '.md')}`
if (meta.published) { i++
i++ items += `
items += ` <item>
<item> <title>${meta.title}</title>
<title>${meta.title}</title> <description>${meta.description}</description>
<description>${meta.description}</description> <link>${link}</link>
<link>${link}</link> <pubDate>${meta.date.toUTCString()}</pubDate>
<pubDate>${meta.date.toUTCString()}</pubDate> <guid>${link}</guid>
<guid>${link}</guid> </item>`
</item>`
}
if (i==15) {break} if (i==15) {break}
} }