Skip to content

[Feature request] Use comments in markdown to create content slots #594

Closed
@frandiox

Description

@frandiox

Feature request

Hi! Thanks for all the job done in VuePress, loving it so far!
I'd like to suggest a way to provide content slots directly from markdown.

What problem does this feature solve?

Currently, I believe that all the markdown in a file is provided by a single <Content> component (except the excerpt part). In order to split the content in different sections we can use slotted components as follows:

<MyComponent>

* One

  This is the *first* section.

* Two

  This is the *second* section.

</MyComponent>

However, this means we need to copy this structure in every translation file we have (/fr/index.md, /es/index.md, etc.).

Apart from that, I'm building a VuePress site by fetching content from a headless CMS (Contentful, specifically), and will have "writers" (not "programmers") adding content there for some pages. Writing Vue components in markdown would make this a bit harder, and also would couple the content to VuePress.

What does the proposed API look like?

Adding comments such as <!-- slot: my section --> to indicate different sections/slots in markdown. These sections could be provided in different components like <ContentMySection /> or <Content name="my-section" />.

---
...
---

# Title

excerpt

<!-- more -->

Default slot here

<!-- slot: section1 -->

section1 slot here

<!-- slot: section2 -->

section2 slot here

How should this be implemented in your opinion?

Perhaps just like <!-- more --> comment is parsed and extracted as this.$page.excerpt, other comments could also be extracted. The result can be provided as <Content> components or as this.$page.slot.name properties (this might require convert md=>html manually?)

Are you willing to work on this yourself?**

Yes, with some guidance to make it faster and after discussing details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature requestRequest to add a new featureversion: nextPlanned to do or already included in the next(1.0.0) version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions