Skip to content
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

Author isn't displayed on the post #341

Closed
moezubair opened this issue Jan 7, 2024 · 1 comment
Closed

Author isn't displayed on the post #341

moezubair opened this issue Jan 7, 2024 · 1 comment

Comments

@moezubair
Copy link

Hey,

I see that there is author field in the post object for blog, however it does not get displayed and I don't see any reference to it in the templates

export interface Post {
  /** A unique ID number that identifies a post. */
  id: string;

  /** A post’s unique slug – part of the post’s URL based on its name, i.e. a post called “My Sample Page” has a slug “my-sample-page”. */
  slug: string;

  /**  */
  permalink: string;

  /**  */
  publishDate: Date;
  /**  */
  updateDate?: Date;

  /**  */
  title: string;
  /** Optional summary of post content. */
  excerpt?: string;
  /**  */
  image?: ImageMetadata | string;

  /**  */
  category?: string;
  /**  */
  tags?: Array<string>;
  /**  */
  author?: string;

  /**  */
  metadata?: MetaData;

  /**  */
  draft?: boolean;

  /**  */
  Content?: AstroComponentFactory;
  content?: string;

  /**  */
  readingTime?: number;
}

@moonbe77
Copy link

Hey, check the file ListItem.astro, if you add console.log to log the post you can see that the author prop is there but the author is undefined.

const { post } = Astro.props;
console.log(post);

Add an author prop to the frontmatter of any of the posts and you will see it in the logs.

publishDate: 2023-08-09T00:00:00Z
title: Useful tools and resources to create a professional website
...
author: Author Name
...
tags:
  - front-end
  - tools
  - resources

you can render the author adding something like this to the html in the ListItem.astro file

<div>Author: {post.author}</div>

thkruz added a commit to thkruz/astrowind that referenced this issue Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants