Skip to content

Commit

Permalink
refactor: 바뀐 routes 구조 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
gongbughim committed Sep 11, 2022
1 parent b2083a4 commit 9505163
Show file tree
Hide file tree
Showing 37 changed files with 2,188 additions and 1,449 deletions.
3,356 changes: 1,996 additions & 1,360 deletions package-lock.json

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@
"version": "0.0.1",
"scripts": {
"postinstall": "cp -r ./node_modules/blogwasm ./src/lib/blogwasm",
"dev": "svelte-kit dev --host 0.0.0.0",
"build": "svelte-kit build",
"dev": "vite dev --host 0.0.0.0 --port 3000",
"build": "vite build",
"package": "svelte-kit package",
"preview": "svelte-kit preview",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"test": "vitest --run",
"test-files": "vitest --run related",
"test:watch": "vitest",
"lint": "npm run lint:js-files -- . && npm run lint:css-files -- \"src/**/*.{css,svelte,svg}\"",
"lint:js-files": "prettier --check --plugin-search-dir=.",
"lint:js-files": "prettier --ignore-path .gitignore --check --plugin-search-dir=.",
"lint:css-files": "stylelint --config .stylelintrc.json",
"format": "prettier --write --plugin-search-dir=. ."
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.30",
"@sveltejs/kit": "^1.0.0-next.330",
"@sveltejs/kit": "^1.0.0-next.405",
"@testing-library/svelte": "^3.1.1",
"@types/d3": "^7.1.0",
"@types/dedent": "^0.7.0",
"@types/js-yaml": "^4.0.5",
"@types/seedrandom": "^3.0.2",
"@types/three": "^0.140.0",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"@types/three": "^0.144.0",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"autoprefixer": "^10.4.7",
"blogwasm": "https://github.com/gongbughim/blogwasm/releases/download/v0.1.3/blogwasm.tar.gz",
"dedent": "^0.7.0",
"eslint": "^8.15.0",
"eslint": "^8.23.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-svelte3": "^4.0.0",
"feed": "^4.2.2",
"js-yaml": "^4.1.0",
"jsdom": "^19.0.0",
"jsdom": "^20.0.0",
"katex": "^0.15.3",
"mdsvex": "^0.10.5",
"postcss": "^8.4.13",
"postcss-html": "^1.4.1",
"postcss-load-config": "^3.1.4",
"postcss-load-config": "^4.0.1",
"postcss-nested": "^5.0.6",
"prettier": "^2.6.2",
"prettier": "^2.7.1",
"prettier-plugin-svelte": "^2.7.0",
"prism-themes": "^1.9.0",
"rehype-autolink-headings": "^6.1.1",
Expand All @@ -53,25 +53,25 @@
"rehype-slug": "^5.0.1",
"remark-abbr": "^1.4.1",
"remark-math": "^3.0.1",
"stylelint": "^14.8.2",
"stylelint": "^14.11.0",
"stylelint-config-css-modules": "^4.1.0",
"stylelint-config-html": "^1.0.0",
"stylelint-config-html": "^1.1.0",
"stylelint-config-idiomatic-order": "^8.1.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^25.0.0",
"stylelint-config-standard": "^28.0.0",
"stylelint-order": "^5.0.0",
"svelte": "^3.48.0",
"svelte-check": "^2.7.0",
"svelte-cubed": "^0.2.1",
"svelte-preprocess": "^4.10.6",
"three": "^0.140.2",
"ts-essentials": "^9.1.2",
"three": "^0.144.0",
"ts-essentials": "^9.3.0",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"unist-util-visit": "^4.1.0",
"typescript": "^4.8.3",
"unist-util-visit": "^4.1.1",
"vite": "^3.1.0",
"vite-plugin-wasm-pack": "^0.1.11",
"vitest": "^0.12.6",
"vitest-svelte-kit": "^0.0.6"
"vitest": "^0.23.2"
},
"type": "module"
}
14 changes: 6 additions & 8 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/// <reference types="@sveltejs/kit" />

// See https://kit.svelte.dev/docs/typescript
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
interface Locals {}

interface Platform {}

interface Session {}

interface Stuff {}
// interface Locals {}
// interface Platform {}
// interface Session {}
// interface Stuff {}
}
6 changes: 3 additions & 3 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%svelte.head%
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
%svelte.body%
%sveltekit.body%
</body>
</html>
Binary file added src/assets/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/fonts/NotoSansKR-VF-distilled.woff2
Binary file not shown.
Binary file added src/assets/fonts/NotoSerifKR-VF-distilled.woff2
Binary file not shown.
93 changes: 93 additions & 0 deletions src/assets/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2012 Google Inc. All Rights Reserved.

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
23 changes: 17 additions & 6 deletions src/lib/css/root.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
@import url('https://fonts.googleapis.com/css2?family=Nanum+Myeongjo:wght@700&display=swap');
@import 'prism-themes/themes/prism-vsc-dark-plus.css';

@font-face {
font-display: swap;
font-family: 'Noto Sans KR';
src: url('$assets/fonts/NotoSansKR-VF-distilled.woff2') format('woff2');
}

@font-face {
font-display: swap;
font-family: 'Noto Serif KR';
src: url('$assets/fonts/NotoSerifKR-VF-distilled.woff2') format('woff2');
}

* {
box-sizing: border-box;
transition-duration: 0.5s;
Expand All @@ -24,8 +35,8 @@
accent-color: var(--c-accent);
background-color: var(--c-bg);
color: var(--c-fg);
font-family: sans-serif;
font-size: 16px;
font-family: "Noto Sans KR", sans-serif;
font-variation-settings: 'wght' 300;
line-height: 1.8;
word-break: keep-all;
}
Expand All @@ -36,8 +47,8 @@ h3,
h4,
h5,
h6 {
font-family: 'Nanum Myeongjo', serif;
font-weight: 700;
font-family: 'Noto Serif KR', serif;
font-variation-settings: 'wght' 400;
}

a {
Expand Down Expand Up @@ -178,7 +189,7 @@ article.post {
strong {
border-bottom: 1px solid var(--c-accent-bg1);
box-shadow: inset 0 -0.6em 0 var(--c-accent-bg0);
font-family: 'Nanum Myeongjo', serif;
font-family: 'Noto Serif', serif;
}

img {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/server/article.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fss from 'fs'
import fs from 'fs/promises'
import yaml from 'js-yaml'

Expand All @@ -24,8 +25,7 @@ export type ArticleMeta = {
*/
export async function getArticleMetas(dir: string): Promise<ArticleMeta[]> {
const promises = (await fs.readdir(dir))
.filter(f => f.endsWith('.md'))
.map(f => f.replace(/\.md$/, ''))
.filter(f => fss.existsSync(`${dir}/${f}/+page.md`))
.map(id => getArticleMeta(dir, id))
return (await Promise.all(promises)).sort((a, b) => (a.publishedAt < b.publishedAt ? 1 : -1))
}
Expand All @@ -37,7 +37,7 @@ export async function getArticleMetas(dir: string): Promise<ArticleMeta[]> {
* @returns Metadata of article
*/
export async function getArticleMeta(dir: string, id: string): Promise<ArticleMeta> {
const filepath = `${dir}/${id}.md`
const filepath = `${dir}/${id}/+page.md`
const f = await fs.readFile(filepath)
const mtime = (await fs.stat(filepath)).mtime

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const prerender = true
8 changes: 8 additions & 0 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getArticleMetas } from '$lib/server/article'

import type { PageServerLoad } from './$types'

export const load: PageServerLoad = async () => {
const posts = await getArticleMetas('src/routes/posts')
return { posts }
}
7 changes: 4 additions & 3 deletions src/routes/index.svelte → src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script lang="ts">
import conf from '$lib/conf'
import type { ArticleMeta } from '$lib/server/article'
export let posts: ArticleMeta[] = []
import type { PageData } from './$types'
$: publishedPosts = posts.filter(p => !p.draft)
export let data: PageData
let posts = data.posts
let publishedPosts = posts.filter(p => !p.draft)
</script>

<svelte:head>
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions src/routes/index.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { beforeEach, expect, test } from 'vitest'
import { getQueryAPI } from '$lib/utils'

// @ts-ignore: *.md is not supported by typescript
import About from './about.md'
import About from './+page.md'

beforeEach(cleanup)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/routes/rss.xml.ts → src/routes/rss.xml/+server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { RequestHandler } from '@sveltejs/kit'
import { Feed } from 'feed'

import conf from '$lib/conf'
import { getArticleMetas } from '$lib/server/article'

export const get: RequestHandler = async () => {
import type { RequestHandler } from './$types'

export const prerender = true

export const GET: RequestHandler = async () => {
const posts = await getArticleMetas('src/routes/posts')
const feed = new Feed({
title: conf.title,
Expand All @@ -28,8 +31,5 @@ export const get: RequestHandler = async () => {
})
})

return {
body: feed.rss2(),
headers: { 'Content-Type': 'text/xml; charset=utf-8' },
}
return new Response(feed.rss2(), { headers: { 'Content-Type': 'text/xml; charset=utf-8' } })
}
13 changes: 6 additions & 7 deletions src/routes/sitemap.xml.ts → src/routes/sitemap.xml/+server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { RequestHandler } from '@sveltejs/kit'

import conf from '$lib/conf'
import { getArticleMetas } from '$lib/server/article'

export const get: RequestHandler = async () => {
import type { RequestHandler } from './$types'

export const prerender = true

export const GET: RequestHandler = async () => {
const posts = await getArticleMetas('src/routes/posts')
const links = posts.map(
p => `
Expand All @@ -19,8 +21,5 @@ export const get: RequestHandler = async () => {
${links.join('')}
</sitemapindex>
`.trim()
return {
body: xml,
headers: { 'Content-Type': 'text/xml; charset=utf-8' },
}
return new Response(xml, { headers: { 'Content-Type': 'text/xml; charset=utf-8' } })
}

0 comments on commit 9505163

Please sign in to comment.