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 permalink feature #285

Open
humbinal opened this issue Apr 14, 2021 · 5 comments
Open

Add permalink feature #285

humbinal opened this issue Apr 14, 2021 · 5 comments
Labels
build Related to the build system enhancement New feature or request has-workaround Has workaround, low priority stale

Comments

@humbinal
Copy link

Did vitpress support permalink in frontmatter? I try to config but not work.

@seangwright
Copy link

The docs show this feature as missing from Vitepress

https://vitepress.vuejs.org/guide/differences-from-vuepress.html#general

@kiaking kiaking added enhancement New feature or request build Related to the build system labels May 24, 2022
@kiaking kiaking changed the title How to use permalink in vitepress? Add permalink feature May 24, 2022
@brc-dd brc-dd added the has-workaround Has workaround, low priority label Jan 28, 2023
@lipengzhou
Copy link

+1

@kid1412621
Copy link

It's the only blocker for me to migrate from vuepress.

@github-actions github-actions bot added the stale label Aug 3, 2023
@brc-dd brc-dd removed the stale label Aug 3, 2023
@StefanoCecere
Copy link

sorry i didn't understand if permalinks (a must have for me, too) has a working workaround or not.
or if it'll every have

@github-actions github-actions bot added the stale label Sep 16, 2023
@brc-dd
Copy link
Member

brc-dd commented Sep 16, 2023

Regarding the has-workaround label, you can use rewrites to write some code like this. Feel free to customize it or comment here if you're having any issues. Note that you'll need to restart the server (press r on terminal) each time you create a new file or add date in it's frontmatter to regenerate rewrites.

// .vitepress/config.ts

import { defineConfig } from 'vitepress'
import fg from 'fast-glob'
import matter from 'gray-matter'

const rewrites = {}
const pages = await fg('**/*.md', { ignore: ['node_modules/**'] })

pages.map((page) => {
  const { date } = matter.read(page).data as { date: Date }

  if (date)
    rewrites[page] = `${date.getFullYear()}/${
      date.getMonth() + 1
    }/${date.getDate()}/${page}`
})

export default defineConfig({
  rewrites
})

@brc-dd brc-dd removed the stale label Sep 16, 2023
@github-actions github-actions bot added the stale label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system enhancement New feature or request has-workaround Has workaround, low priority stale
Projects
None yet
Development

No branches or pull requests

7 participants