forked from tanner/qotnews
fun.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import fetch from 'isomorphic-fetch';
|
||||
|
||||
// const API_URL = process.env.API_URL || 'http://news.1j.nz';
|
||||
const API_URL = process.env.API_URL || 'http://localhost:33842';
|
||||
|
||||
export async function get(req, res) {
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<script>
|
||||
import fromUnixTime from "date-fns/fromUnixTime";
|
||||
import Comment from "../components/Comment.svelte";
|
||||
import StoryInfo from "../components/StoryInfo.svelte";
|
||||
import Article from "../components/Article.svelte";
|
||||
export let story;
|
||||
export let related;
|
||||
|
||||
@@ -23,25 +23,13 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* .article {
|
||||
}
|
||||
.article-header {
|
||||
}
|
||||
|
||||
.article-header .article-title {
|
||||
}
|
||||
|
||||
.article-header .article-byline {
|
||||
}
|
||||
.article-body {
|
||||
} */
|
||||
.article-body :global(img) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
margin: 3rem 0;
|
||||
}
|
||||
.single {
|
||||
max-width: 56rem;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
@@ -54,41 +42,37 @@
|
||||
<meta property="article:author" content={story.author || story.source} />
|
||||
</svelte:head>
|
||||
|
||||
<article class="article">
|
||||
<header class="article-header">
|
||||
<h1 class="article-title">{story.title}</h1>
|
||||
<StoryInfo class="article-byline" {story} />
|
||||
</header>
|
||||
<section class="single">
|
||||
<Article {story} />
|
||||
|
||||
<section class="article-body">
|
||||
{@html story.text}
|
||||
</section>
|
||||
</article>
|
||||
{#if hasComments}
|
||||
<hr class="spacer" />
|
||||
|
||||
{#if hasComments}
|
||||
<hr class="spacer" />
|
||||
<section id="comments">
|
||||
<header>
|
||||
<h2>Comments</h2>
|
||||
|
||||
<section class="comments" id="comments">
|
||||
<header>
|
||||
<h2>Comments</h2>
|
||||
|
||||
{#if others.length}
|
||||
<h3>
|
||||
Other discussions:
|
||||
{#each others as r}
|
||||
{#if r.num_comments}
|
||||
<a href="/{r.id}#comments" rel="prefetch">{r.source}</a>
|
||||
{/if}
|
||||
{#if others.length}
|
||||
<h3>
|
||||
Other discussions:
|
||||
{#each others as r}
|
||||
{#if r.num_comments}
|
||||
<a href="/{r.id}#comments" rel="prefetch">
|
||||
{r.source}
|
||||
({r.num_comments})
|
||||
</a>
|
||||
{/if}
|
||||
{/each}
|
||||
</h3>
|
||||
{/if}
|
||||
</header>
|
||||
{#if story.comments.length}
|
||||
<div class="comments">
|
||||
{#each story.comments as comment}
|
||||
<Comment {story} {comment} />
|
||||
{/each}
|
||||
</h3>
|
||||
</div>
|
||||
{/if}
|
||||
</header>
|
||||
{#if story.comments.length}
|
||||
<div class="comments">
|
||||
{#each story.comments as comment}
|
||||
<Comment {story} {comment} />
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
</section>
|
||||
|
@@ -6,9 +6,9 @@
|
||||
<style>
|
||||
main {
|
||||
position: relative;
|
||||
max-width: 56em;
|
||||
max-width: 64rem;
|
||||
background-color: white;
|
||||
padding: 2em;
|
||||
padding: 0.5rem;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import fetch from 'isomorphic-fetch';
|
||||
|
||||
const API_URL = process.env.API_URL || 'http://news.1j.nz';
|
||||
// const API_URL = process.env.API_URL || 'http://localhost:33842';
|
||||
const API_URL = process.env.API_URL || 'http://localhost:33842';
|
||||
|
||||
export async function get(req, res) {
|
||||
const { skip, limit } = {
|
||||
|
@@ -16,74 +16,18 @@
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { stores } from "@sapper/app";
|
||||
import { getLogoUrl } from "../utils/logos.js";
|
||||
import StoryInfo from "../components/StoryInfo.svelte";
|
||||
import StoryList from "../components/StoryList.svelte";
|
||||
import Pagination from "../components/Pagination.svelte";
|
||||
|
||||
export let stories;
|
||||
export let skip;
|
||||
export let limit;
|
||||
|
||||
const { page } = stores();
|
||||
|
||||
page.subscribe((value) => {
|
||||
skip = value.query.skip || 0;
|
||||
limit = value.query.limit || 20;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
article {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin: 3rem 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.pagination-link.is-right {
|
||||
margin-left: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>QotNews</title>
|
||||
<meta property="og:title" content="QotNews" />
|
||||
<meta property="og:type" content="website" />
|
||||
</svelte:head>
|
||||
|
||||
<section>
|
||||
{#each stories as story}
|
||||
<article>
|
||||
<header>
|
||||
<img
|
||||
src={getLogoUrl(story)}
|
||||
alt="logo"
|
||||
style="height: 1rem; width: 1rem;" />
|
||||
<a rel="prefetch" href="/{story.id}">{story.title}</a>
|
||||
(<a
|
||||
href={story.url || story.link}>{new URL(story.url || story.link).hostname.replace(/^www\./, '')}</a>)
|
||||
</header>
|
||||
<section>
|
||||
<StoryInfo {story} />
|
||||
</section>
|
||||
</article>
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
<div class="pagination">
|
||||
{#if Number(skip) > 0}
|
||||
<a
|
||||
class="pagination-link is-left"
|
||||
href="?skip={Number(skip) - Math.min(Number(skip), Number(limit))}&limit={limit}"
|
||||
rel="prefetch">Previous</a>
|
||||
{/if}
|
||||
{#if stories.length == Number(limit)}
|
||||
<a
|
||||
class="pagination-link is-right"
|
||||
href="?skip={Number(skip) + Number(limit)}&limit={limit}"
|
||||
rel="prefetch">Next</a>
|
||||
{/if}
|
||||
</div>
|
||||
<StoryList {stories}>
|
||||
<Pagination href="/" count={stories.length} />
|
||||
</StoryList>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import fetch from 'isomorphic-fetch';
|
||||
|
||||
const API_URL = process.env.API_URL || 'http://news.1j.nz';
|
||||
const API_URL = process.env.API_URL || 'http://localhost:33842';
|
||||
|
||||
export async function get(req, res) {
|
||||
const { skip, limit } = {
|
||||
|
@@ -20,84 +20,23 @@
|
||||
|
||||
<script>
|
||||
import { stores } from "@sapper/app";
|
||||
import { getLogoUrl } from "../utils/logos.js";
|
||||
import StoryInfo from "../components/StoryInfo.svelte";
|
||||
import StoryList from "../components/StoryList.svelte";
|
||||
import Pagination from "../components/Pagination.svelte";
|
||||
|
||||
export let stories;
|
||||
export let skip;
|
||||
export let limit;
|
||||
export let q;
|
||||
|
||||
const { page } = stores();
|
||||
|
||||
page.subscribe((value) => {
|
||||
skip = value.query.skip || 0;
|
||||
limit = value.query.limit || 20;
|
||||
q = value.query.query || "";
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
article {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin: 3rem 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.pagination-link {
|
||||
/* border: solid 1px #aaa;
|
||||
border-radius: 0;
|
||||
background: #f1f1f1;
|
||||
border-radius: 5px;
|
||||
margin: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
text-decoration: none; */
|
||||
}
|
||||
.pagination-link.is-right {
|
||||
margin-left: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>QotNews</title>
|
||||
<meta property="og:title" content="QotNews" />
|
||||
<meta property="og:type" content="website" />
|
||||
</svelte:head>
|
||||
|
||||
<section>
|
||||
{#each stories as story}
|
||||
<article>
|
||||
<header>
|
||||
<img
|
||||
src={getLogoUrl(story)}
|
||||
alt="logo"
|
||||
style="height: 1rem; width: 1rem;" />
|
||||
<a rel="prefetch" href="/{story.id}">{story.title}</a>
|
||||
(<a
|
||||
href={story.url || story.link}>{new URL(story.url || story.link).hostname.replace(/^www\./, '')}</a>)
|
||||
</header>
|
||||
<section>
|
||||
<StoryInfo {story} />
|
||||
</section>
|
||||
</article>
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
<div class="pagination">
|
||||
{#if Number(skip) > 0}
|
||||
<a
|
||||
class="pagination-link is-left"
|
||||
href="?skip={Number(skip) - Math.min(Number(skip), Number(limit))}&limit={limit}"
|
||||
rel="prefetch">Previous</a>
|
||||
{/if}
|
||||
{#if stories.length == Number(limit)}
|
||||
<a
|
||||
class="pagination-link is-right"
|
||||
href="?skip={Number(skip) + Number(limit)}&limit={limit}"
|
||||
rel="prefetch">Next</a>
|
||||
{/if}
|
||||
</div>
|
||||
<StoryList {stories}>
|
||||
<Pagination
|
||||
href="/search"
|
||||
search="q={$page.query.q}"
|
||||
count={stories.length} />
|
||||
</StoryList>
|
||||
|
Reference in New Issue
Block a user