adjustments to behavior and specifications #3

Merged
Hare merged 3 commits from develop into master 2024-08-28 04:40:16 +09:00
6 changed files with 55 additions and 47 deletions

View File

@ -17,6 +17,8 @@ FROM node:22-slim
WORKDIR /app WORKDIR /app
COPY ./articles ./articles
COPY --from=builder /app/build ./build COPY --from=builder /app/build ./build
COPY --from=builder /app/package.json . COPY --from=builder /app/package.json .
COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/node_modules ./node_modules

View File

@ -7,7 +7,7 @@
import FormattedDate from '$lib/components/formatted_date.svelte'; import FormattedDate from '$lib/components/formatted_date.svelte';
import Head from '$lib/components/head.svelte'; import Head from '$lib/components/head.svelte';
import type { Article } from '$lib/article'; import type { Article } from '$lib/article';
export let data: Article; export let data: Article;
</script> </script>
@ -31,38 +31,49 @@
<img src={data.image} alt="" /> <img src={data.image} alt="" />
</div> --> </div> -->
<div class="container"> <div class="container">
<div class="title"> <main>
<h1>{data.title}</h1> <div class="title">
<div class="meta"> <h1>{data.title}</h1>
<span> <div class="meta">
released <FormattedDate date={data.released_at} /> <span>
{#if data.updated_at}<br /> released <FormattedDate date={data.released_at} />
updated <FormattedDate date={data.updated_at} /> {#if data.updated_at}<br />
{/if} updated <FormattedDate date={data.updated_at} />
</span> {/if}
<span> </span>
<a href="/category/{data.category}" <span>
>{data.category[0].toUpperCase() + data.category.slice(1)}</a <a href="/category/{data.category}"
> >{data.category[0].toUpperCase() + data.category.slice(1)}</a
{#each data.tags as tag} >
<a href={`/search?tag=${tag}`}>{tag}</a> {#each data.tags as tag}
{/each} <a href={`/search?tag=${tag}`}>{tag}</a>
</span> {/each}
</span>
</div>
</div> </div>
</div> <div class="panel">
<div class="panel">
<main>
<div class="document"> <div class="document">
<slot /> <slot />
</div> </div>
</main> <Footer />
<Footer /> </div>
</div> </main>
</div> </div>
<style lang="scss"> <style lang="scss">
:global(body) { :global(body) {
overflow: hidden;
background-color: var(--background-primary); background-color: var(--background-primary);
background-size: cover;
background-blend-mode: overlay;
}
.container {
overflow: hidden;
width: 100vw;
height: 100dvh;
backdrop-filter: blur(2px);
overflow-y: auto;
overflow-x: hidden;
} }
.back { .back {
position: fixed; position: fixed;
@ -80,15 +91,19 @@
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
} }
.container { main {
border: 1px solid var(--line-primary);
border-top: none;
border-bottom: none;
box-sizing: border-box;
color: white; color: white;
min-height: 100%; min-height: 100%;
padding: 20px;
padding-top: 100px; padding-top: 100px;
width: 1000px; width: 1000px;
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
box-sizing: border-box;
} }
.title { .title {
h1 { h1 {
@ -138,14 +153,6 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
main {
padding: 20px;
box-sizing: border-box;
width: 1000px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
@media (max-width: 1000px) { @media (max-width: 1000px) {
.container { .container {
width: 100%; width: 100%;
@ -155,8 +162,5 @@
padding: 8px 20px; padding: 8px 20px;
} }
} }
main {
max-width: 100%;
}
} }
</style> </style>

View File

@ -1,5 +1,5 @@
import pg from 'pg'; import pg from 'pg';
import { Pool } from 'pg'; const { Pool } = pg;
import { getConnection } from './database/get_connection'; import { getConnection } from './database/get_connection';
export class Postgres { export class Postgres {

View File

@ -1,5 +1,4 @@
// initialize // initialize
import PG from '$lib/server/database';
import type { Postgres } from '$lib/server/database'; import type { Postgres } from '$lib/server/database';
import fs from 'fs'; import fs from 'fs';
import { compile } from 'mdsvex'; import { compile } from 'mdsvex';
@ -108,6 +107,7 @@ export default async function init(db: Postgres) {
for (const { path, id } of articleFiles) { for (const { path, id } of articleFiles) {
const res = await db.query('select * from article where id = $1', [id]); const res = await db.query('select * from article where id = $1', [id]);
const compiled = await compile(fs.readFileSync(path, 'utf-8')); const compiled = await compile(fs.readFileSync(path, 'utf-8'));
const title = compiled.data.fm.title; const title = compiled.data.fm.title;
const category = path.split('/')[3]; const category = path.split('/')[3];
const tags: string[] = compiled.data.fm.tags; const tags: string[] = compiled.data.fm.tags;
@ -127,8 +127,8 @@ export default async function init(db: Postgres) {
} else if (res.rows[0].updated_at < updated_at) { } else if (res.rows[0].updated_at < updated_at) {
console.log(`Update article: ${id}`); console.log(`Update article: ${id}`);
await db.query( await db.query(
'update article set title = $2, updated_at = $4, tags = $5, content = $6 where id = $1', 'update article set title = $2, category = $3, released_at = $4, updated_at = $5, tags = $6, image = $7, publish = $8, content = $9 where id = $1',
[id, title, updated_at, tags, content] [id, title, category, released_at, updated_at, tags, image, publish, content]
); );
} else { } else {
console.log(`Article ${id} is already up-to-date`); console.log(`Article ${id} is already up-to-date`);

View File

@ -41,7 +41,10 @@
<style lang="scss"> <style lang="scss">
:global(body) { :global(body) {
background-color: var(--background-primary); overflow: hidden;
background-color: var(--background-primary);
background-size: cover;
background-blend-mode: overlay;
} }
.back { .back {
position: fixed; position: fixed;

View File

@ -114,8 +114,8 @@
</div> </div>
<Footer /> <Footer />
</main> </main>
<Cursor />
</div> </div>
<Cursor />
<style lang="scss"> <style lang="scss">
:global(body) { :global(body) {
@ -129,7 +129,8 @@
width: 100vw; width: 100vw;
height: 100dvh; height: 100dvh;
backdrop-filter: blur(2px); backdrop-filter: blur(2px);
overflow: hidden; overflow-y: auto;
overflow-x: hidden;
} }
.controls { .controls {
position: fixed; position: fixed;
@ -146,12 +147,10 @@
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
max-width: 1000px; max-width: 1000px;
height: 100dvh;
color: white; color: white;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-x: hidden; overflow: visible;
overflow-y: auto;
> div { > div {
margin: 10px 0; margin: 10px 0;
} }