Compare commits

...

8 Commits

Author SHA1 Message Date
57efc611cd change: dev build & publish falseの投稿に目印をつけるなどをした 2024-12-15 20:16:48 +09:00
d22b5cfc6f add: dev ticker 2024-12-15 20:02:19 +09:00
164f97999e add: 見出しの高さを制限 2024-12-08 00:17:51 +09:00
cf48e00138 change: svelte5 対応 2024-12-08 00:16:43 +09:00
3d253508d0 fix: 文字コード指定 2024-12-08 00:16:10 +09:00
e5e8123d51 add: code hide button 2024-12-08 00:15:11 +09:00
43c3eb92e0 add: markdown tale layout 2024-12-08 00:13:38 +09:00
0dc53871b6 add: KaTex対応 2024-12-07 21:02:00 +09:00
11 changed files with 362 additions and 22 deletions

267
package-lock.json generated
View File

@ -12,11 +12,13 @@
"github-slugger": "^2.0.0",
"rehype-external-links": "^3.0.0",
"rehype-highlight": "^7.0.1",
"rehype-katex": "^7.0.1",
"rehype-slug": "^6.0.0",
"rehype-stringify": "^10.0.1",
"remark": "^15.0.1",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"remark-rehype": "^11.1.1",
"yaml": "^2.6.0"
},
@ -866,6 +868,12 @@
"@types/unist": "*"
}
},
"node_modules/@types/katex": {
"version": "0.16.7",
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz",
"integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==",
"license": "MIT"
},
"node_modules/@types/mdast": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
@ -996,6 +1004,15 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/commander": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
"integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
},
"node_modules/cookie": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
@ -1075,6 +1092,18 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/entities": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/esbuild": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@ -1185,6 +1214,75 @@
"dev": true,
"license": "MIT"
},
"node_modules/hast-util-from-dom": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/hast-util-from-dom/-/hast-util-from-dom-5.0.1.tgz",
"integrity": "sha512-N+LqofjR2zuzTjCPzyDUdSshy4Ma6li7p/c3pA78uTwzFgENbgbUrm2ugwsOdcjI1muO+o6Dgzp9p8WHtn/39Q==",
"license": "ISC",
"dependencies": {
"@types/hast": "^3.0.0",
"hastscript": "^9.0.0",
"web-namespaces": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-from-html": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.3.tgz",
"integrity": "sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"devlop": "^1.1.0",
"hast-util-from-parse5": "^8.0.0",
"parse5": "^7.0.0",
"vfile": "^6.0.0",
"vfile-message": "^4.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-from-html-isomorphic": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-2.0.0.tgz",
"integrity": "sha512-zJfpXq44yff2hmE0XmwEOzdWin5xwH+QIhMLOScpX91e/NSGPsAzNCvLQDIEPyO2TXi+lBmU6hjLIhV8MwP2kw==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"hast-util-from-dom": "^5.0.0",
"hast-util-from-html": "^2.0.0",
"unist-util-remove-position": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-from-parse5": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.2.tgz",
"integrity": "sha512-SfMzfdAi/zAoZ1KkFEyyeXBn7u/ShQrfd675ZEE9M3qj+PMFX05xubzRyF76CCSJu8au9jgVxDV1+okFvgZU4A==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/unist": "^3.0.0",
"devlop": "^1.0.0",
"hastscript": "^9.0.0",
"property-information": "^6.0.0",
"vfile": "^6.0.0",
"vfile-location": "^5.0.0",
"web-namespaces": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-heading-rank": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/hast-util-heading-rank/-/hast-util-heading-rank-3.0.0.tgz",
@ -1211,6 +1309,19 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-parse-selector": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz",
"integrity": "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hast-util-to-html": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.3.tgz",
@ -1276,6 +1387,23 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/hastscript": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-9.0.0.tgz",
"integrity": "sha512-jzaLBGavEDKHrc5EfFImKN7nZKKBdSLIdGvCwDZ9TfzbF2ffXiov8CKE445L2Z1Ek2t/m4SKQ2j6Ipv7NyUolw==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^4.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/highlight.js": {
"version": "11.10.0",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.10.0.tgz",
@ -1340,6 +1468,22 @@
"@types/estree": "^1.0.6"
}
},
"node_modules/katex": {
"version": "0.16.11",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.11.tgz",
"integrity": "sha512-RQrI8rlHY92OLf3rho/Ts8i/XvjgguEjOkO1BEXcU3N8BqPpSzBNwV/G0Ukr+P/l3ivvJUE/Fa/CwbS6HesGNQ==",
"funding": [
"https://opencollective.com/katex",
"https://github.com/sponsors/katex"
],
"license": "MIT",
"dependencies": {
"commander": "^8.3.0"
},
"bin": {
"katex": "cli.js"
}
},
"node_modules/kleur": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
@ -1543,6 +1687,25 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-math": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-3.0.0.tgz",
"integrity": "sha512-Tl9GBNeG/AhJnQM221bJR2HPvLOSnLE/T9cJI9tlc6zwQk2nPk/4f0cHkOdEixQPC/j8UtKDdITswvLAy1OZ1w==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/mdast": "^4.0.0",
"devlop": "^1.0.0",
"longest-streak": "^3.0.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-markdown": "^2.1.0",
"unist-util-remove-position": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-newline-to-break": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-newline-to-break/-/mdast-util-newline-to-break-2.0.0.tgz",
@ -1816,6 +1979,25 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-extension-math": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-3.1.0.tgz",
"integrity": "sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg==",
"license": "MIT",
"dependencies": {
"@types/katex": "^0.16.0",
"devlop": "^1.0.0",
"katex": "^0.16.0",
"micromark-factory-space": "^2.0.0",
"micromark-util-character": "^2.0.0",
"micromark-util-symbol": "^2.0.0",
"micromark-util-types": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-factory-destination": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz",
@ -2234,6 +2416,18 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/parse5": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz",
"integrity": "sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==",
"license": "MIT",
"dependencies": {
"entities": "^4.5.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@ -2315,6 +2509,25 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-katex": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz",
"integrity": "sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/katex": "^0.16.0",
"hast-util-from-html-isomorphic": "^2.0.0",
"hast-util-to-text": "^4.0.0",
"katex": "^0.16.0",
"unist-util-visit-parents": "^6.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-slug": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/rehype-slug/-/rehype-slug-6.0.0.tgz",
@ -2396,6 +2609,22 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-math": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/remark-math/-/remark-math-6.0.0.tgz",
"integrity": "sha512-MMqgnP74Igy+S3WwnhQ7kqGlEerTETXMvJhrUzDikVZ2/uogJCb+WHUg97hK9/jcfc0dkD73s3LN8zU49cTEtA==",
"license": "MIT",
"dependencies": {
"@types/mdast": "^4.0.0",
"mdast-util-math": "^3.0.0",
"micromark-extension-math": "^3.0.0",
"unified": "^11.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/remark-parse": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz",
@ -2676,6 +2905,20 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-remove-position": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-5.0.0.tgz",
"integrity": "sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-visit": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -2732,6 +2975,20 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-location": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz",
"integrity": "sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==",
"license": "MIT",
"dependencies": {
"@types/unist": "^3.0.0",
"vfile": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/vfile-message": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz",
@ -2825,6 +3082,16 @@
}
}
},
"node_modules/web-namespaces": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
"integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/yaml": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz",

View File

@ -19,11 +19,13 @@
"github-slugger": "^2.0.0",
"rehype-external-links": "^3.0.0",
"rehype-highlight": "^7.0.1",
"rehype-katex": "^7.0.1",
"rehype-slug": "^6.0.0",
"rehype-stringify": "^10.0.1",
"remark": "^15.0.1",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"remark-rehype": "^11.1.1",
"yaml": "^2.6.0"
}

View File

@ -78,6 +78,22 @@
background-color: #fff0;
}
}
& table {
margin: 1rem auto;
font-size: 1.2em;
border-collapse: collapse;
& thead {
border-bottom: solid 1px var(--black-white);
}
& tbody tr:nth-child(2n) {
background-color: color-mix(in srgb, var(--black-white) 10%, var(--back-color));
}
& td,th {
border-width: 0px;
padding: .3em .6em;
}
}
& blockquote {
position: relative;
font-style: italic;
@ -145,4 +161,13 @@
width: 60%;
}
}
& .katex-html {
display: none;
}
& .katex-display {
& math {
margin: 1rem;
font-size: 1.5rem;
}
}
}

View File

@ -1,11 +1,15 @@
<script>
export let mdtext;
import { onMount } from "svelte";
import { remark } from 'remark'
import remarkgfm from 'remark-gfm'
import remarkBreaks from "remark-breaks"
import remarkmath from 'remark-math'
import remarkRehype from 'remark-rehype'
import rehypeslug from 'rehype-slug'
import rehypeKatex from 'rehype-katex'
import rehypeHighlight from 'rehype-highlight'
import rehypeExternalLinks from 'rehype-external-links'
import rehypeStringify from 'rehype-stringify'
@ -17,13 +21,36 @@
let md = remark()
.use(remarkgfm) // Github Markdown
.use(remarkBreaks) // 改行
.use(remarkmath) // 数式
.use(remarkRehype, {allowDangerousHtml: true})
.use(rehypeslug) // headingにidを設定
.use(rehypeKatex) // 数式
.use(rehypeHighlight)// Syntax highlight
.use(rehypeExternalLinks, {target:'_blank', rel:['noreferrer','noopener']})// 外部サイトを新規タブで開く
.use(rehypeStringify, {allowDangerousHtml: true})
.processSync(mdtext)
onMount(()=>{
let toggleHide = function(e){
let iframes = document.getElementsByTagName('iframe')
for ( let i = 0; i < iframes.length; i++ ){
try{
console.log(iframes[i].contentWindow.name)
if (e.origin === window.origin && iframes[i].contentWindow.name == e.data.id){
iframes[i].classList.toggle('hide')
}
}catch(e){
console.log(e)
}
}
}
window.addEventListener('message', toggleHide)
return ()=>{window.removeEventListener('message', toggleHide)}
})
</script>
<div class='markdown'>

View File

@ -10,7 +10,6 @@ async function Metadatas() {
const cache_dir = '/tmp/day.moris.blog/';
const cache_file = `${cache_dir}metadata.json`;
async function build() {
const posts = await Posts();
@ -20,9 +19,11 @@ async function Metadatas() {
return {postId, metadata}
}))
const sorted = metadataList.sort((a,b)=>{
const sorted = metadataList
.sort((a,b)=>{
return b.metadata.date.getTime() - a.metadata.date.getTime()
})
.filter((m)=> dev||m.metadata.published)
return sorted
}

View File

@ -3,6 +3,7 @@
import Header from "./header.svelte";
import Footer from "./footer.svelte";
import { onMount } from 'svelte';
import { dev } from '$app/environment'
let { children } = $props();
@ -19,6 +20,9 @@
<div id="root">
<div id="scroll"></div>
{#if dev}
<div id='devTicker'>DEV DUILD</div>
{/if}
<div class="headerContainer">
<header class:hide={!scrollObserver}>
@ -45,13 +49,23 @@
min-height: 100vh;
}
#devTicker {
position: fixed;
top: 0;
left: 0;
padding: 6px;
color: yellow;
background-color: #0008;
z-index: 10;
}
.headerContainer {
position: sticky;
top: 0;
height: 100px;
height: 80px;
z-index: 1;
@media(width<1000px) {
height: 50px;
height: 40px;
}
& header {
@ -59,7 +73,7 @@
height: 100%;
transition: height .4s, transform .4s;
&.hide {
height: 50px;
height: 40px;
@media(width<1000px) {
transform: translate(0px,-50px);
}
@ -96,6 +110,6 @@
}
@media (scripting: none) {
.headerContainer{height:50px !important;}
.headerContainer{height:40px !important;}
}
</style>

View File

@ -7,13 +7,11 @@
<div class='contain'>
<div class="posts">
{#each data.posts as post}
{#if post.metadata.published}
<div class="post">
<div class="post" class:published={!post.metadata.published}>
<a style='text-decoration: none;' href="../post/{post.postId}" tabindex="0">
<Postgrid id={post.postId} {...post.metadata}></Postgrid>
</a>
</div>
{/if}
{/each}
{#if data.posts.length%4}
{#each Array(4-data.posts.length%4) as i}
@ -48,6 +46,10 @@
border-radius: 8px;
overflow: hidden;
box-shadow: 0 0 6px #0001;
&.published {
border: solid red 3px;
}
}
.paging {

View File

@ -24,6 +24,8 @@
margin: 0;
padding: 5px;
font-size: .9rem;
max-height: 280px;
overflow: scroll;
}
li {
padding: 4px;

View File

@ -1,4 +1,6 @@
<script>
let { children } = $props();
import './app.css'
function toggleFullScreen() {
@ -25,7 +27,7 @@
<button style="background-color: rgb(40 200 64)" aria-label="fullscreen" onclick={toggleFullScreen}></button>
</div>
<div class="code">
<slot />
{@render children()}
</div>
</div>

View File

@ -4,7 +4,7 @@ import fs from 'node:fs';
export async function load({params}) {
const code = params.slug.replace(/\.html$/, "");
const html = fs.readFileSync(`${POST_DIR}/Codes/${code}.html`);
const html = fs.readFileSync(`${POST_DIR}/Codes/${code}.html`, 'utf-8');
return {html}
}

View File

@ -18,17 +18,15 @@ export async function GET() {
let meta = post.metadata
let link = `https://${PUBLIC_HOSTNAME}/blog/post/${path.basename(post.postId, '.md')}`
if (meta.published) {
i++
items += `
<item>
<title>${meta.title}</title>
<description>${meta.description}</description>
<link>${link}</link>
<pubDate>${meta.date.toUTCString()}</pubDate>
<guid>${link}</guid>
</item>`
}
i++
items += `
<item>
<title>${meta.title}</title>
<description>${meta.description}</description>
<link>${link}</link>
<pubDate>${meta.date.toUTCString()}</pubDate>
<guid>${link}</guid>
</item>`
if (i==15) {break}
}