Skip to content

Commit

Permalink
fix(git-changelog): normalize path prefix (#39)
Browse files Browse the repository at this point in the history
Signed-off-by: Neko Ayaka <[email protected]>
  • Loading branch information
nekomeowww authored Jan 1, 2024
1 parent 4fdbda6 commit 0fb8777
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig(async () => {
GitChangelog({
repoURL: () => 'https://github.com/nolebase/integrations',
rewritePaths: {
docs: '',
'docs/': '',
},
}),
GitChangelogMarkdownSection({
Expand Down
2 changes: 1 addition & 1 deletion packages/vitepress-plugin-git-changelog/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nolebase/vitepress-plugin-git-changelog",
"type": "module",
"version": "1.3.1",
"version": "1.3.2",
"description": "A VitePress plugin that adds a changelog fetched from git to your documentation.",
"author": {
"name": "Nólëbase",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ const isFreshChange = computed(() => {
>
<label cursor-pointer>
<div
class="flex select-none items-center justify-between hover:text-$vp-c-brand-1"
class="vp-nolebase-git-changelog-title flex select-none items-center justify-between"
transition="color ease-in-out"
text="<sm:xs" duration-200
>
<span class="inline-flex items-center gap-3 text-$vp-custom-block-details-text">
<span class="vp-nolebase-git-changelog-last-edited-title inline-flex items-center gap-3">
<span class="i-octicon:history-16" />
<span v-if="commits[0]">
{{ t('lastEdited', { props: { daysAgo: lastChangeDate?.fromNow() } }) }}
</span>
</span>
<input v-model="toggleViewMore" type="checkbox" invisible appearance-none>
<span class="inline-flex items-center gap-3 !font-400">
<span class="vp-nolebase-git-changelog-view-full-history-title inline-flex items-center gap-3">
<span class="<sm:hidden">
{{ t('viewFullHistory') }}
</span>
Expand Down Expand Up @@ -121,3 +121,22 @@ const isFreshChange = computed(() => {
</VerticalTransition>
</div>
</template>

<style scoped>
.vp-nolebase-git-changelog-title {
color: var(--vp-custom-block-details-text);
font-size: var(--vp-custom-block-font-size);
}
.vp-nolebase-git-changelog-title:hover {
color: var(--vp-c-brand-1);
}
.vp-nolebase-git-changelog-last-edited-title {
font-weight: 800;
}
.vp-nolebase-git-changelog-view-full-history-title {
font-weight: 400;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { useRoute } from 'vitepress'

export function useRawPath() {
const route = useRoute()

return computed(() => {
let path = decodeURIComponent(route.path).toLowerCase()
if (path.startsWith('/'))
path = path.slice(1)

if (path.endsWith('/'))
path += 'index.md'
else
path = path.replace(/^\/(.+?)(\.html)?$/s, '$1.md')
path = path.replace(/^(.+?)(\.html)?$/s, '$1.md')

return path.toLowerCase()
})
Expand Down

0 comments on commit 0fb8777

Please sign in to comment.