+
Skip to content

fix(content): filter out string content when using agx files #1200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2024
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
28 changes: 13 additions & 15 deletions apps/ng-app/src/app/pages/posts.[slug].page.analog
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,22 @@ import { PostAttributes } from './models';
const renderer = inject(ContentRenderer);
const post$ = injectContent<PostAttributes>();

const toc$ = this.post$.pipe(
const toc$ = post$.pipe(
map(() => {
return this.renderer.getContentHeadings();
return renderer.getContentHeadings();
})
);
</script>

<template>
<ng-container *ngIf="post$ | async as post">
<h1>{{ post.attributes.title }}</h1>
<div *ngIf="toc$ | async as toc">
<ul>
<li *ngFor="let item of toc">
<a href="#{{ item.id }}">{{ item.text }}</a>
</li>
</ul>
</div>
<template><ng-container *ngIf="post$ | async as post">
<h1>{{ post.attributes.title }}</h1>
<div *ngIf="toc$ | async as toc">
<ul>
<li *ngFor="let item of toc">
<a href="#{{ item.id }}">{{ item.text }}</a>
</li>
</ul>
</div>

<analog-markdown [content]="post.content"></analog-markdown>
</ng-container>
</template>
<analog-markdown [content]="post.content"></analog-markdown>
</ng-container></template>
3 changes: 2 additions & 1 deletion packages/content/src/lib/markdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { ActivatedRoute, Data } from '@angular/router';
import { Observable, from, of } from 'rxjs';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { catchError, map, mergeMap, filter } from 'rxjs/operators';

import { AnchorNavigationDirective } from './anchor-navigation.directive';
import { ContentRenderer } from './content-renderer';
Expand Down Expand Up @@ -85,6 +85,7 @@ export default class AnalogMarkdownComponent
getContentSource() {
return this.route.data.pipe(
map<Data, string>((data) => this.content ?? data['_analogContent']),
filter((content) => typeof content === 'string'),
mergeMap((contentString) => this.renderContent(contentString)),
map((content) => this.sanitizer.bypassSecurityTrustHtml(content)),
catchError((e) => of(`There was an error ${e}`))
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载