diff --git a/webapp/src/components/Comment.svelte b/webapp/src/components/Comment.svelte index bbed67e..6384246 100644 --- a/webapp/src/components/Comment.svelte +++ b/webapp/src/components/Comment.svelte @@ -7,7 +7,7 @@ export let dateString = formatDistanceToNow(fromUnixTime(comment.date), { addSuffix: true, }); - const author = comment.author.replace(" ", ""); + const author = (comment.author || "").replace(" ", ""); export let id = `${author}-${comment.date}`; export function toggleComments() { @@ -16,45 +16,98 @@ -
-
- {comment.author} - | - {dateString} +
+
+ {comment.author || '[Deleted]'} + • + + + {#if comment.comments.length} {/if} -
-
+ + +
{@html comment.text} -
- {#if showComments && comment.comments.length} + + + {#if !showComments}
+ +
+ {/if} + + {#if showComments && comment.comments.length} +
+ {/if} - + diff --git a/webapp/src/components/StoryInfo.svelte b/webapp/src/components/StoryInfo.svelte index 0c7ebaa..955c1ca 100644 --- a/webapp/src/components/StoryInfo.svelte +++ b/webapp/src/components/StoryInfo.svelte @@ -2,27 +2,25 @@ import fromUnixTime from "date-fns/fromUnixTime"; import formatDistanceToNow from "date-fns/formatDistanceToNow"; export let story; - export let dateString = formatDistanceToNow(fromUnixTime(story.date), { addSuffix: true, }); - - - -{#if story.author && story.author_link} - by - {story.author} -{:else if story.author}by {story.author}{/if} -on -{story.source} -{#if story.score}• {story.score} points{/if} -{#if story.num_comments} - • - {story.num_comments} - comments -{/if} +
+ + {#if story.author && story.author_link} + by + {story.author} + {:else if story.author}by {story.author}{/if} + on + {story.source} + {#if story.score}• {story.score} points{/if} + {#if story.num_comments} + • + {story.num_comments} + comments + {/if} +
diff --git a/webapp/src/routes/[id].json.js b/webapp/src/routes/[id].json.js index dd0bd52..c9f5c7f 100644 --- a/webapp/src/routes/[id].json.js +++ b/webapp/src/routes/[id].json.js @@ -1,9 +1,9 @@ -import fetch from 'node-fetch'; +import fetch from 'isomorphic-fetch'; + +const API_URL = process.env.API_URL || 'http://news.1j.nz'; export async function get(req, res) { - const response = await fetch(`http://localhost:33842/api/${req.params.id}`); - res.writeHead(200, { - 'Content-Type': 'application/json' - }); + const response = await fetch(`${API_URL}/api/${req.params.id}`); + res.writeHead(response.status, { 'Content-Type': 'application/json' }); res.end(await response.text()); } \ No newline at end of file diff --git a/webapp/src/routes/[id].svelte b/webapp/src/routes/[id].svelte index 70c7b06..6b34eaf 100644 --- a/webapp/src/routes/[id].svelte +++ b/webapp/src/routes/[id].svelte @@ -1,7 +1,5 @@ - News + QotNews + +
diff --git a/webapp/src/template.html b/webapp/src/template.html index 7c0f817..b9794c2 100644 --- a/webapp/src/template.html +++ b/webapp/src/template.html @@ -11,23 +11,11 @@ - %sapper.scripts% - - %sapper.styles% - - %sapper.head% -
%sapper.html%