Skip to content

Commit

Permalink
feat: x関連のボタンを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yossydev committed Mar 5, 2024
1 parent 6492ef1 commit cc78295
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
38 changes: 38 additions & 0 deletions app/islands/share.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { LINK } from "../constants";

export default function Share({ title }: { title: string }) {
if (typeof window === "undefined") {
return (
<div class="flex items-center justify-center mt-10 gap-3 ">
<div role="status" class="max-w-sm animate-pulse w-full">
<div class="h-11 bg-gray-200 rounded-3xl w-full" />
</div>
</div>
);
}
return (
<div class="flex items-center justify-center mt-10 gap-3">
<a
href={`https://twitter.com/share?url=${window.location.href}&text=${title}`}
target={"_blank"}
rel={"noreferrer"}
class="bg-[#0f1419] text-white flex items-center text-sm rounded-3xl py-3 px-4"
>
<img
src="/static/twitter-alt.svg"
alt="xにシェアする"
class="w-4 h-4 mr-1"
/>
Post
</a>
<a
href={LINK.X}
target={"_blank"}
rel={"noreferrer"}
class="bg-gray-200 flex items-center text-sm rounded-3xl py-3 px-4"
>
Follow @yossydev
</a>
</div>
);
}
15 changes: 7 additions & 8 deletions app/routes/_renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Style } from "hono/css";
import { jsxRenderer } from "hono/jsx-renderer";
import { Script } from "honox/server";
import { HasIslands, Script } from "honox/server";
import { LINK } from "../constants";

export default jsxRenderer(({ children, title, description }) => {
Expand All @@ -27,14 +27,13 @@ export default jsxRenderer(({ children, title, description }) => {
) : (
<link href="/app/style.css" rel="stylesheet" />
)}
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" />
<script>hljs.highlightAll();</script>
</head>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" />
<script>hljs.highlightAll();</script>

<body class="main-container">
<header class="mt-3 bg-black">
<div class="max-w-screen-2xl mx-auto flex h-16 items-center justify-between px-6">
Expand Down
8 changes: 4 additions & 4 deletions app/routes/posts/_renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { jsxRenderer } from "hono/jsx-renderer";
import Share from "../../islands/share";

export default jsxRenderer(({ children, Layout, frontmatter }) => {
const _title = `${frontmatter?.title} | yossy.dev`;
return (
<Layout
title={`${frontmatter?.title} | yossy.dev`}
description={frontmatter?.description}
>
<Layout title={_title} description={frontmatter?.description}>
<div class="markdown">{children}</div>
<Share title={_title} />
</Layout>
);
});
11 changes: 11 additions & 0 deletions app/routes/posts/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createRoute } from "honox/factory";
import Share from "../../islands/share";

export default createRoute((c) => {
return c.render(
<div>
<h1>Hello</h1>
</div>,
{},
);
});

0 comments on commit cc78295

Please sign in to comment.