add VISIBLE_DRAFT for showing drafts in the list
All checks were successful
Build & Depoly / Depoly blog (push) Successful in 1m41s
All checks were successful
Build & Depoly / Depoly blog (push) Successful in 1m41s
This commit is contained in:
parent
9ec980839a
commit
85ded53035
3 changed files with 42 additions and 22 deletions
|
@ -1,23 +1,36 @@
|
|||
import { defineConfig } from "astro/config";
|
||||
import { defineConfig, envField } from "astro/config";
|
||||
import solidJs from "@astrojs/solid-js";
|
||||
import mdx from "@astrojs/mdx";
|
||||
import icon from "astro-icon";
|
||||
import paths from "node:path"
|
||||
import paths from "node:path";
|
||||
import rehypeBuckTable from "~/support/rehype-buck-tables";
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
integrations: [solidJs(), mdx(), icon(), {
|
||||
name: "inject-cloudflare-headers",
|
||||
"hooks": {
|
||||
"astro:config:setup": ({injectRoute}) => {
|
||||
injectRoute({
|
||||
pattern: "/_headers",
|
||||
entrypoint: "./src/pages/_headers.ts",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
env: {
|
||||
schema: {
|
||||
VISIBLE_DRAFT: envField.boolean({
|
||||
context: "server",
|
||||
access: "public",
|
||||
default: false,
|
||||
}),
|
||||
},
|
||||
},
|
||||
integrations: [
|
||||
solidJs(),
|
||||
mdx(),
|
||||
icon(),
|
||||
{
|
||||
name: "inject-cloudflare-headers",
|
||||
hooks: {
|
||||
"astro:config:setup": ({ injectRoute }) => {
|
||||
injectRoute({
|
||||
pattern: "/_headers",
|
||||
entrypoint: "./src/pages/_headers.ts",
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
markdown: {
|
||||
rehypePlugins: [rehypeBuckTable],
|
||||
|
@ -25,14 +38,14 @@ export default defineConfig({
|
|||
themes: {
|
||||
light: "github-light",
|
||||
dark: "github-dark",
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
vite: {
|
||||
resolve: {
|
||||
alias: {
|
||||
"~": paths.resolve(import.meta.dir, "src")
|
||||
}
|
||||
}
|
||||
}
|
||||
"~": paths.resolve(import.meta.dir, "src"),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "bunx --bun astro dev",
|
||||
"dev": "VISIBLE_DRAFT=true bunx --bun astro dev",
|
||||
"dist": "bunx --bun astro build",
|
||||
"preview": "bunx --bun astro preview",
|
||||
"posts": "bun run scripts/postman.ts"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { CollectionEntry } from "astro:content";
|
||||
import { VISIBLE_DRAFT } from "astro:env/server";
|
||||
|
||||
function toPadLeft(n: number) {
|
||||
if (n < 10) {
|
||||
|
@ -24,7 +25,9 @@ export function postParamlink(post: CollectionEntry<"posts">) {
|
|||
}
|
||||
|
||||
export function getAllTags(posts: CollectionEntry<"posts">[]) {
|
||||
const tags = new Set(posts.filter(shouldBeVisible).flatMap((post) => post.data.tags || []));
|
||||
const tags = new Set(
|
||||
posts.filter(shouldBeVisible).flatMap((post) => post.data.tags || []),
|
||||
);
|
||||
|
||||
return tags.values().toArray().sort();
|
||||
}
|
||||
|
@ -75,5 +78,9 @@ export function getHotTags(posts: CollectionEntry<"posts">[], tags: string[]) {
|
|||
}
|
||||
|
||||
export function shouldBeVisible(post: CollectionEntry<"posts">) {
|
||||
return !post.data.visibility || post.data.visibility === "visible"
|
||||
return (
|
||||
!post.data.visibility ||
|
||||
post.data.visibility === "visible" ||
|
||||
(VISIBLE_DRAFT && post.data.visibility === "draft")
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue