Skip to content

Commit

Permalink
feat: add top image
Browse files Browse the repository at this point in the history
  • Loading branch information
ocknamo committed May 28, 2024
1 parent 6763ad4 commit 4f50215
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name: Node.js CI

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -20,14 +19,14 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run format
- run: npm run lint
- run: npm run build
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run format
- run: npm run lint
- run: npm run build
# - run: npm run ci:test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You can preview the production build with `npm run preview`.
## Future work(TODO)

- Preview for Nostr Events in article
- Preview for Nostr Events in article
- Config
- Black list
- Thumbnail image
Expand Down
10 changes: 6 additions & 4 deletions src/lib/server/blog-store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ export class BlogStoreService {
const blogs: Blog[] = events
.map((e) => {
const identifierTag = e.tags.find((t) => t[0] === 'd') ?? [];
const title = e.tags.find((t) => t[0] === 'title') ?? [];
const summary = e.tags.find((t) => t[0] === 'summary') ?? [];
const titleTag = e.tags.find((t) => t[0] === 'title') ?? [];
const summaryTag = e.tags.find((t) => t[0] === 'summary') ?? [];
const imageTag = e.tags.find((t) => t[0] === 'image') ?? [];
const hashTags = e.tags.filter((t) => t[0] === 't').map((t) => t[1]);
return {
...e,
identifier: identifierTag[1],
title: title[1],
summary: summary[1],
title: titleTag[1],
summary: summaryTag[1],
image: imageTag[1],
hashTags
};
})
Expand Down
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { NostrEventExt } from 'nostr-fetch';
export interface Blog extends NostrEventExt {
title: string;
summary: string;
image: string;
hashTags: string[];
identifier: string;
naddress: string;
Expand Down
9 changes: 9 additions & 0 deletions src/routes/blog/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
</script>

<hgroup>
{#if !!data.blog.image}
<img class="image" src={data.blog.image} alt="thumbnail" />
{/if}
<h1>{data.blog.title}</h1>
<p class="naddress">
naddress: <a
Expand Down Expand Up @@ -45,6 +48,12 @@
max-width: 800px;
}
hgroup img {
min-width: 100%;
max-height: 320px;
object-fit: cover;
}
hgroup .naddress {
font-size: 0.8rem;
}
Expand Down

0 comments on commit 4f50215

Please sign in to comment.