Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions libs/shared/feature/src/pages/blog/[slug].page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// /src/app/pages/blog/posts.[slug].page.ts
import { injectContent, MarkdownComponent } from '@analogjs/content';
import { AsyncPipe } from '@angular/common';
import { Component } from '@angular/core';

export interface PostAttributes {
title: string;
slug: string;
description: string;
coverImage: string;
}

@Component({
standalone: true,
imports: [MarkdownComponent, AsyncPipe],
template: `
@if (post$ | async; as post) {
<h1>{{ post.attributes.title }}</h1>
<analog-markdown [content]="post.content"></analog-markdown>
}
`,
})
export default class BlogPostComponent {
readonly post$ = injectContent<PostAttributes>();
}
6 changes: 5 additions & 1 deletion packages/content/src/lib/content-files-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const CONTENT_FILES_TOKEN = new InjectionToken<
Object.entries(allFiles).forEach((entry) => {
const filename = entry[0];
const value = entry[1];
const strippedFilename = filename.replace(
/^\/(.*?)\/content/,
'/src/content',
);

const newFilename = lookup[filename];
const newFilename = lookup[strippedFilename];
if (newFilename !== undefined) {
const objectFilename = newFilename.replace(
/^\/(.*?)\/content/,
Expand Down