From cc36f0edf5c80ae3a96ed427ee319aa01a5cf0c9 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Thu, 8 Aug 2024 08:26:32 -0400 Subject: [PATCH] Add dev-mode into the posts handler. --- posts/fullstack-hono.md | 4 +--- src/assets/static/main.css | 17 +++++++++++++ src/assets/static/tomorrow.css | 44 ---------------------------------- src/handlers/posts.tsx | 7 ++++++ src/templates/Page.tsx | 2 +- 5 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 src/assets/static/tomorrow.css diff --git a/posts/fullstack-hono.md b/posts/fullstack-hono.md index b52c4b8..7b2319b 100644 --- a/posts/fullstack-hono.md +++ b/posts/fullstack-hono.md @@ -153,9 +153,7 @@ app.get( ## Development -If the environment variable `ENVIRONMENT` is set and the value is `DEVELOPMENT` -then we can easily grab all the Posts, including Drafts, from the -`PostService`. +If the environment variable `DEPLOY_MODE` is set and the value is `DEVELOPMENT` then we can easily grab all the Posts, including Drafts, so I can see how my content will be rendered out to the page. ## Deployment diff --git a/src/assets/static/main.css b/src/assets/static/main.css index f8c50f4..a19846c 100644 --- a/src/assets/static/main.css +++ b/src/assets/static/main.css @@ -9,6 +9,23 @@ header { border-bottom: 1px solid #ccc; } +header .home-link { + font-size: 18pt; +} + +header .home-link a { + color: #00e; +} +header .home-link a:visited { + color: #00e; +} + footer { border-top: 1px solid #ccc; } + +pre code.hljs { + border: 1px solid #ccc; + border-radius: 5px; + background-color: #fafafa; +} diff --git a/src/assets/static/tomorrow.css b/src/assets/static/tomorrow.css deleted file mode 100644 index 8cf8a38..0000000 --- a/src/assets/static/tomorrow.css +++ /dev/null @@ -1,44 +0,0 @@ -/* Tomorrow Theme */ -/* https://jmblog.github.io/color-themes-for-google-code-highlightjs */ -/* Original theme - https://github.com/chriskempson/tomorrow-theme */ -/* https://jmblog.github.io/color-themes-for-google-code-highlightjs */ -.tomorrow-comment, pre .comment, pre .title { - color: #8e908c; -} - -.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo { - color: #c82829; -} - -.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant { - color: #f5871f; -} - -.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute { - color: #eab700; -} - -.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata { - color: #718c00; -} - -.tomorrow-aqua, pre .css .hexcolor { - color: #3e999f; -} - -.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title { - color: #4271ae; -} - -.tomorrow-purple, pre .keyword, pre .javascript .function { - color: #8959a8; -} - -pre code { - display: block; - background: white; - color: #4d4d4c; - line-height: 1.5; - border: 1px solid #ccc; - padding: 10px; -} diff --git a/src/handlers/posts.tsx b/src/handlers/posts.tsx index 0269740..9bb923b 100644 --- a/src/handlers/posts.tsx +++ b/src/handlers/posts.tsx @@ -16,6 +16,13 @@ export async function handleSinglePost(c: Context) { try { const post = postService.getPost(postSlug); + + if (process.env.DEPLOY_MODE !== "development") { + if (post.meta.draft) { + throw Error("Unable to find post."); + } + } + const meta: SiteMeta = { description: post.meta.description, tags: post.meta.tags, diff --git a/src/templates/Page.tsx b/src/templates/Page.tsx index 3649b51..5a87bcc 100644 --- a/src/templates/Page.tsx +++ b/src/templates/Page.tsx @@ -14,7 +14,7 @@ export function Page({ children, meta }: { children: any, meta: SiteMeta }) {
-
+