soames-astro-theme 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -8,10 +8,17 @@ import HeroHeader from "@theme/components/HeroHeader";
|
|
|
8
8
|
import Shortcodes from "@theme/components/shortcodes/Shortcodes";
|
|
9
9
|
import Bio from "@theme/components/Bio";
|
|
10
10
|
import BlogSidebar from "@theme/components/BlogSidebar";
|
|
11
|
-
import { getPosts } from "../../../lib/wp";
|
|
11
|
+
import { getPosts, getPostsPage } from "../../../lib/wp";
|
|
12
12
|
|
|
13
13
|
export async function getStaticPaths() {
|
|
14
14
|
const posts = await getPosts();
|
|
15
|
+
// Single posts inherit the posts page (blog roll) hero — title, background
|
|
16
|
+
// image, overlay — falling back to "Blog" / placeholder when none is set.
|
|
17
|
+
// Fetched once here and shared across all paths (one WP round-trip).
|
|
18
|
+
const postsPage = await getPostsPage();
|
|
19
|
+
const heroTitle = postsPage?.title ?? "Blog";
|
|
20
|
+
const heroBg = postsPage?.featuredImage?.sourceUrl ?? null;
|
|
21
|
+
const heroOverlay = postsPage?.overlayOpacity ?? null;
|
|
15
22
|
return posts.map((post, i) => ({
|
|
16
23
|
params: { slug: post.slug },
|
|
17
24
|
props: {
|
|
@@ -19,11 +26,14 @@ export async function getStaticPaths() {
|
|
|
19
26
|
posts,
|
|
20
27
|
previous: posts[i + 1] ?? null, // posts are date DESC → next index is older
|
|
21
28
|
next: posts[i - 1] ?? null,
|
|
29
|
+
heroTitle,
|
|
30
|
+
heroBg,
|
|
31
|
+
heroOverlay,
|
|
22
32
|
},
|
|
23
33
|
}));
|
|
24
34
|
}
|
|
25
35
|
|
|
26
|
-
let { post, posts, previous, next } = Astro.props;
|
|
36
|
+
let { post, posts, previous, next, heroTitle, heroBg, heroOverlay } = Astro.props;
|
|
27
37
|
|
|
28
38
|
// Dev only: re-fetch on each request so WP edits show on refresh without
|
|
29
39
|
// restarting `astro dev` (getStaticPaths props are cached otherwise). Stripped
|
|
@@ -37,6 +47,10 @@ if (import.meta.env.DEV) {
|
|
|
37
47
|
previous = all[i + 1] ?? null;
|
|
38
48
|
next = all[i - 1] ?? null;
|
|
39
49
|
}
|
|
50
|
+
const pp = await getPostsPage();
|
|
51
|
+
heroTitle = pp?.title ?? "Blog";
|
|
52
|
+
heroBg = pp?.featuredImage?.sourceUrl ?? null;
|
|
53
|
+
heroOverlay = pp?.overlayOpacity ?? null;
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
const img = post.featuredImage;
|
|
@@ -44,7 +58,7 @@ const fmtDate = (d: string) =>
|
|
|
44
58
|
new Date(d).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "2-digit" });
|
|
45
59
|
---
|
|
46
60
|
<Base pageTitle={post.title} description={post.excerpt}>
|
|
47
|
-
<HeroHeader title=
|
|
61
|
+
<HeroHeader title={heroTitle} subhead="" backgroundImage={heroBg} overlayOpacity={heroOverlay} />
|
|
48
62
|
<section>
|
|
49
63
|
<div class="media-container-row">
|
|
50
64
|
<div class="col-12 col-lg-8">
|
|
@@ -7,7 +7,7 @@ import Base from "@theme/layouts/Base.astro";
|
|
|
7
7
|
import HeroHeader from "@theme/components/HeroHeader";
|
|
8
8
|
import Shortcodes from "@theme/components/shortcodes/Shortcodes";
|
|
9
9
|
import DocsSidebar from "@theme/components/DocsSidebar";
|
|
10
|
-
import { getDocs, buildDocTree } from "../../lib/wp";
|
|
10
|
+
import { getDocs, buildDocTree, getDocsPage } from "../../lib/wp";
|
|
11
11
|
|
|
12
12
|
export async function getStaticPaths() {
|
|
13
13
|
// Derive the [...slug] param from the doc's WP uri (e.g. /docs/getting-started/
|
|
@@ -19,16 +19,23 @@ export async function getStaticPaths() {
|
|
|
19
19
|
|
|
20
20
|
const docs = await getDocs();
|
|
21
21
|
const tree = buildDocTree(docs);
|
|
22
|
+
// Single docs inherit the /docs/ page hero — title, background image, overlay —
|
|
23
|
+
// falling back to "Documentation" / placeholder when none is set. Fetched once
|
|
24
|
+
// here and shared across all paths (one WP round-trip).
|
|
25
|
+
const docsPage = await getDocsPage();
|
|
26
|
+
const heroTitle = docsPage?.title ?? "Documentation";
|
|
27
|
+
const heroBg = docsPage?.featuredImage?.sourceUrl ?? null;
|
|
28
|
+
const heroOverlay = docsPage?.overlayOpacity ?? null;
|
|
22
29
|
return docs
|
|
23
30
|
.map((doc) => ({ doc, slug: toSlug(doc.uri) }))
|
|
24
31
|
.filter(({ slug }) => slug.length > 0)
|
|
25
32
|
.map(({ doc, slug }) => ({
|
|
26
33
|
params: { slug },
|
|
27
|
-
props: { doc, tree },
|
|
34
|
+
props: { doc, tree, heroTitle, heroBg, heroOverlay },
|
|
28
35
|
}));
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
let { doc, tree } = Astro.props;
|
|
38
|
+
let { doc, tree, heroTitle, heroBg, heroOverlay } = Astro.props;
|
|
32
39
|
|
|
33
40
|
// Dev only: re-fetch on each request so WP doc edits show on refresh without
|
|
34
41
|
// restarting `astro dev` (getStaticPaths props are cached otherwise). Stripped
|
|
@@ -41,10 +48,14 @@ if (import.meta.env.DEV) {
|
|
|
41
48
|
doc = fresh;
|
|
42
49
|
tree = buildDocTree(docs);
|
|
43
50
|
}
|
|
51
|
+
const dp = await getDocsPage();
|
|
52
|
+
heroTitle = dp?.title ?? "Documentation";
|
|
53
|
+
heroBg = dp?.featuredImage?.sourceUrl ?? null;
|
|
54
|
+
heroOverlay = dp?.overlayOpacity ?? null;
|
|
44
55
|
}
|
|
45
56
|
---
|
|
46
57
|
<Base pageTitle={doc.title} description={doc.excerpt}>
|
|
47
|
-
<HeroHeader title=
|
|
58
|
+
<HeroHeader title={heroTitle} subhead="" backgroundImage={heroBg} overlayOpacity={heroOverlay} />
|
|
48
59
|
<section>
|
|
49
60
|
<div class="media-container-row">
|
|
50
61
|
<div class="col-12 col-lg-8">
|