-
Notifications
You must be signed in to change notification settings - Fork 30
在页面历史中插入 Typst 历史版本 #166
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
Merged
Merged
在页面历史中插入 Typst 历史版本 #166
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import type { Plugin } from 'vite'; | ||
|
|
||
| import { TYPST_TAGS_FOR_NOLEBASE } from '../theme/typst_version'; | ||
|
|
||
| export function TypstTagsForNolebase(): Plugin { | ||
| const name = 'zhtyp-guide-typst-version'; | ||
| const virtualModuleId = `virtual:${name}`; | ||
| const resolvedVirtualModuleId = `\0${virtualModuleId}`; | ||
|
|
||
| return { | ||
| name, | ||
| resolveId(id: string) { | ||
| if (id === virtualModuleId) { | ||
| return resolvedVirtualModuleId; | ||
| } | ||
| }, | ||
| load(id: string) { | ||
| if (id !== resolvedVirtualModuleId) { | ||
| return; | ||
| } | ||
|
|
||
| return `export default ${JSON.stringify(TYPST_TAGS_FOR_NOLEBASE)};`; | ||
| }, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| diff --git a/dist/client/composables/changelog.mjs b/dist/client/composables/changelog.mjs | ||
| index f63b201c453809ad5a5797360ce3f55a70ee6581..cadb0547b88485f5a71bafbc79e1da480a5d9da5 100644 | ||
| --- a/dist/client/composables/changelog.mjs | ||
| +++ b/dist/client/composables/changelog.mjs | ||
| @@ -2,6 +2,20 @@ import changelog from "virtual:nolebase-git-changelog"; | ||
| import { useData } from "vitepress"; | ||
| import { computed, ref, toValue } from "vue"; | ||
| import { isStringArray } from "../utils.mjs"; | ||
| + | ||
| +import TYPST_TAGS_FOR_NOLEBASE from "virtual:zhtyp-guide-typst-version" | ||
| + | ||
| +const TYPST_FAKE_COMMITS = TYPST_TAGS_FOR_NOLEBASE.map(( | ||
| + { date_timestamp, tag, release_tag_url }, | ||
| +) => ({ | ||
| + date_timestamp, | ||
| + authors: [], | ||
| + tag, | ||
| + tags: [tag], | ||
| + release_tag_url, | ||
| + release_tags_url: [release_tag_url], | ||
| +})); | ||
| + | ||
| export function useChangelog() { | ||
| const { page } = useData(); | ||
| const gitChangelog = ref(changelog); | ||
| @@ -10,10 +24,17 @@ export function useChangelog() { | ||
| const _commits = computed(() => { | ||
| const currentPath = toValue(page.value.filePath); | ||
| const allCommits = gitChangelog.value.commits; | ||
| - const commits2 = allCommits.filter((c) => c.paths.includes(currentPath)) || []; | ||
| - return commits2.sort((a, b) => b.date_timestamp - a.date_timestamp).filter((commit, index) => { | ||
| - if (commit.tag && (!commits2[index + 1] || commits2[index + 1]?.tag)) | ||
| - return false; | ||
| + const commits2 = TYPST_FAKE_COMMITS.concat(allCommits.filter((c) => c.paths.includes(currentPath)) || []); | ||
| + return commits2.sort((a, b) => b.date_timestamp - a.date_timestamp).filter((commit, index, arr) => { | ||
| + // Drop irrelevant tags | ||
| + if (commit.tag) { | ||
| + // `prev` & `next` are in the sense of time, not the position in the array | ||
| + const next = arr[index - 1]; | ||
| + const prev = arr[index + 1]; | ||
| + // Keep a tag if and only if it's adjacent to a regular commit. | ||
| + return (next && !next.tag) || (prev && !prev.tag); | ||
| + } | ||
| + // Keep all regular commits | ||
| return true; | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.