Add dev-mode into the posts handler.

This commit is contained in:
Dave Smith-Hayes 2024-08-08 08:26:32 -04:00
parent bd883ac4ef
commit cc36f0edf5
5 changed files with 26 additions and 48 deletions

View File

@ -153,9 +153,7 @@ app.get(
## Development ## Development
If the environment variable `ENVIRONMENT` is set and the value is `DEVELOPMENT` 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.
then we can easily grab all the Posts, including Drafts, from the
`PostService`.
## Deployment ## Deployment

View File

@ -9,6 +9,23 @@ header {
border-bottom: 1px solid #ccc; 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 { footer {
border-top: 1px solid #ccc; border-top: 1px solid #ccc;
} }
pre code.hljs {
border: 1px solid #ccc;
border-radius: 5px;
background-color: #fafafa;
}

View File

@ -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;
}

View File

@ -16,6 +16,13 @@ export async function handleSinglePost(c: Context) {
try { try {
const post = postService.getPost(postSlug); const post = postService.getPost(postSlug);
if (process.env.DEPLOY_MODE !== "development") {
if (post.meta.draft) {
throw Error("Unable to find post.");
}
}
const meta: SiteMeta = { const meta: SiteMeta = {
description: post.meta.description, description: post.meta.description,
tags: post.meta.tags, tags: post.meta.tags,

View File

@ -14,7 +14,7 @@ export function Page({ children, meta }: { children: any, meta: SiteMeta }) {
</head> </head>
<body> <body>
<header> <header>
<div> <div class="home-link">
<a href="/">davesmithhayes.com</a> <a href="/">davesmithhayes.com</a>
</div> </div>
</header> </header>