-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
159 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { getHostname } from '@/lib/env' | ||
import { getInfo } from '@/lib/api/workers' | ||
import { FullArticle } from '@/components/large/article' | ||
|
||
export const runtime = 'edge' | ||
|
||
export function generateMetadata() { | ||
return { | ||
title: 'Post for nostter | Maretol Base', | ||
description: 'about Post for nostter', | ||
openGraph: { | ||
title: 'Post for nostter | Maretol Base', | ||
description: 'about Post for nostter', | ||
url: getHostname() + '/artifacts/post-for-nostter', | ||
}, | ||
} | ||
} | ||
|
||
export default async function PostForNostter() { | ||
const contents = await getInfo() | ||
|
||
const postForNostterContent = contents.filter( | ||
(c) => c.page_pathname === '/artifacts/post-for-nostter' || c.page_pathname === 'artifacts/post-for-nostter' | ||
)[0] | ||
|
||
const host = getHostname() | ||
const path = '/artifacts/post-for-nostter' | ||
const url = `${host}${path}` | ||
|
||
return ( | ||
<div className="flex flex-col justify-center gap-10"> | ||
<FullArticle | ||
id={'post-for-nostter'} | ||
title="Post for nostter" | ||
publishedAt={postForNostterContent.publishedAt} | ||
updatedAt={postForNostterContent.updatedAt} | ||
categories={[]} | ||
rawContent={''} | ||
parsedContents={postForNostterContent.parsed_content} | ||
tableOfContents={postForNostterContent.table_of_contents} | ||
type="info" | ||
shareURL={url} | ||
/> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
// CMSデータの h1, h2... は、ブログ内のコンテンツに合わせたときタイトルを h1 とする都合でそれぞれ一つずつ下の階層に置換する | ||
export default function Hn({ tag, text }: { tag: string; text: string }) { | ||
export default function Hn({ tag, text, attrs }: { tag: string; text: string; attrs?: { [key: string]: string } }) { | ||
const id = attrs?.id ? attrs.id : undefined | ||
|
||
if (tag === 'h1') { | ||
return ( | ||
<div className="pt-6 pb-3 space-y-0"> | ||
<h2 className="text-xl font-bold pl-2 pb-1 content-h2">{text}</h2> | ||
<h2 id={id} className="text-xl font-bold pl-2 pb-1 content-h2"> | ||
{text} | ||
</h2> | ||
</div> | ||
) | ||
} | ||
if (tag === 'h2') { | ||
return ( | ||
<div className="pt-6 pb-3 space-y-0"> | ||
<h3 className="text-lg font-bold border-blue-900 pl-3 border-l-4">{text}</h3> | ||
<h3 id={id} className="text-lg font-bold border-blue-900 pl-3 border-l-4"> | ||
{text} | ||
</h3> | ||
</div> | ||
) | ||
} | ||
if (tag === 'h3') { | ||
return ( | ||
<div className="flex flex-row items-center pt-4 space-x-2"> | ||
<div className="w-2 h-2 rounded-full bg-blue-900 inline-block"></div> | ||
<h4 className="text-lg font-bold">{text}</h4> | ||
<h4 id={id} className="text-lg font-bold"> | ||
{text} | ||
</h4> | ||
</div> | ||
) | ||
} | ||
if (tag === 'h4') { | ||
return ( | ||
<div className="flex flex-row items-center pt-4 pb-4 space-x-2"> | ||
<div className="w-2 h-1 rounded-full bg-blue-900 inline-block"></div> | ||
<h5 className="font-bold ">{text}</h5> | ||
<h5 id={id} className="font-bold "> | ||
{text} | ||
</h5> | ||
</div> | ||
) | ||
} | ||
if (tag === 'h5') { | ||
return <h6 className="pt-2">{text}</h6> | ||
return ( | ||
<h6 id={id} className="pt-2"> | ||
{text} | ||
</h6> | ||
) | ||
} | ||
return <p>{text}</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { TableOfContents } from 'api-types' | ||
|
||
export default function Table({ toc }: { toc: TableOfContents }) { | ||
let beforeLevel = 0 | ||
return ( | ||
<div className="bg-gray-100 p-4 rounded-lg"> | ||
<h2 className="text-lg font-bold">Contents</h2> | ||
<div className="ml-4 mt-2"> | ||
{toc.map((t, i) => { | ||
if (t.level <= 1) { | ||
const levelDown = beforeLevel > t.level | ||
beforeLevel = t.level | ||
return ( | ||
<div key={i} className={`ml-2` + (levelDown ? ' mt-1' : '')}> | ||
<p className="font-semibold"> | ||
<a className="hover:underline" href={`#${t.id}`}> | ||
{t.title} | ||
</a> | ||
</p> | ||
</div> | ||
) | ||
} else if (t.level === 2) { | ||
const levelDown = beforeLevel > t.level | ||
beforeLevel = t.level | ||
return ( | ||
<div key={i} className={`ml-6` + (levelDown ? ' mt-1' : '')}> | ||
<p className="font-semibold"> | ||
<a className="hover:underline" href={`#${t.id}`}> | ||
{t.title} | ||
</a> | ||
</p> | ||
</div> | ||
) | ||
} else if (t.level === 3) { | ||
const levelDown = beforeLevel > t.level | ||
beforeLevel = t.level | ||
return ( | ||
<div key={i} className={`ml-10` + (levelDown ? ' mt-1' : '')}> | ||
<p className="font-semibold"> | ||
<a className="hover:underline" href={`#${t.id}`}> | ||
{t.title} | ||
</a> | ||
</p> | ||
</div> | ||
) | ||
} else { | ||
const levelDown = beforeLevel > t.level | ||
beforeLevel = t.level | ||
return ( | ||
<div key={i} className={`ml-14` + (levelDown ? ' mt-1' : '')}> | ||
<p className="font-semibold"> | ||
<a className="hover:underline" href={`#${t.id}`}> | ||
{t.title} | ||
</a> | ||
</p> | ||
</div> | ||
) | ||
} | ||
})} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters