Skip to content

Commit

Permalink
fix: display blog posts
Browse files Browse the repository at this point in the history
  • Loading branch information
jrson83 committed Jul 12, 2024
1 parent a818a4c commit a42dcc3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
6 changes: 2 additions & 4 deletions _build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
type BuildMode = string | undefined

const createConfig = (mode: BuildMode) => {
const createConfig = (mode?: string) => {
if (typeof mode === 'undefined') {
throw new Error('BUILD_MODE is not defined')
}
Expand All @@ -16,6 +14,6 @@ const createConfig = (mode: BuildMode) => {
}
}

const BUILD_MODE: BuildMode = Deno.env.get('BUILD_MODE')
const BUILD_MODE = Deno.env.get('BUILD_MODE')

export const config = createConfig(BUILD_MODE)
2 changes: 1 addition & 1 deletion plugins/md5-cache-buster/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function (userOptions?: Partial<Options>) {
site.addEventListener('afterRender', () => {
site.process(options.extensions, (pages) => pages.forEach(buildHash))

site.process(['.html'], replaceUrls)
site.process(['.html'], (pages) => pages.forEach(replaceUrls))
})

function buildHash(page: Lume.Page) {
Expand Down
2 changes: 1 addition & 1 deletion src/_components/layout/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default (
{ activeUrl, comp, icons, search }: Lume.PageProps,
{ urlFilter }: Lume.Helpers,
) => {
const items = search.pages('menu.visible=true', 'menu.order')
const items = search.pages<Lume.PageProps>('menu.visible=true', 'menu.order')

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/blog.tmpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export const indexable = true
export const layout = 'layouts/posts.tsx'
export const importJs = '/scripts/search.js'

export default function* ({ paginate, search }: Lume.Data) {
const posts = search.pages('type=post', 'date=desc')
export default function* ({ paginate, search }: Lume.PageProps) {
const posts = search.pages<Lume.PageProps>('type=post', 'date=desc')
const options = {
url: (n: number) => n == 1 ? `/blog/` : `/blog/${n}/`,
size: 4,
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const title = 'Home'
export const layout = 'layouts/root.tsx'

export default ({ comp, search }: Lume.Data) => {
const posts = search.pages('type=post', 'date=desc', 3)
const posts = search.pages<Lume.Data>('type=post', 'date=desc', 3)

return (
<>
Expand Down Expand Up @@ -38,7 +38,7 @@ export default ({ comp, search }: Lume.Data) => {
<hr />
<h2>Recent posts</h2>
<section itemScope itemType='http://schema.org/Blog'>
{posts.map(({ data }, index) => (
{posts.map((data, index) => (
<comp.blog.post index={index.toString()} {...data} />
))}
{posts?.length === 0 && <p>Sorry, no posts matched your criteria.</p>}
Expand Down
4 changes: 1 addition & 3 deletions src/posts/_data.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { Page } from '#types'

export const indexable = true
export const type = 'post'
export const layout = 'layouts/post.tsx'
export const importJs = '/scripts/blog.js'

export function url(page: Page): string {
export function url(page: Lume.Page): string {
return `/blog/${page.data.title}/`
}

0 comments on commit a42dcc3

Please sign in to comment.