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

add slug based on filename to ContentFile data #247

Closed
1 of 2 tasks
d-koppenhagen opened this issue Feb 2, 2023 · 0 comments · Fixed by #248
Closed
1 of 2 tasks

add slug based on filename to ContentFile data #247

d-koppenhagen opened this issue Feb 2, 2023 · 0 comments · Fixed by #248
Labels
enhancement New feature or request

Comments

@d-koppenhagen
Copy link
Contributor

Which scope/s are relevant/related to the feature request?

content

Information

The slug for the URL of a content page (markdown) can currently be explicitely added using a frontmatter attribute or by extracting it form the filename which is part of the ContentFile interface. It would be neat it the slug can be provided by the content plugin based on the filename without removing manually the path and extension parts form the filename string.

Suggestion

export interface ContentFile< Attributes extends Record<string, any> = Record<string, any>> {
  filename: string;
+ slug: string;
  content?: string;
  attributes: Attributes;
}

Example

{
  attributes: { ... }
  filename: "/src/content/2023-foo-bar.md",
+ slug: "2023-foo-bar"
}

The slug should be URLEncoded.

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@d-koppenhagen d-koppenhagen added the enhancement New feature or request label Feb 2, 2023
d-koppenhagen added a commit to d-koppenhagen/analog that referenced this issue Feb 2, 2023
d-koppenhagen added a commit to d-koppenhagen/analog that referenced this issue Feb 2, 2023
Villanuevand pushed a commit to Villanuevand/analog that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant