-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds a basic interface for tagging documents, searching by tags, and quick-links for available tags / search to the sidebar
- Loading branch information
Showing
23 changed files
with
487 additions
and
172 deletions.
There are no files selected for viewing
This file contains 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 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 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,39 @@ | ||
import React from "react"; | ||
import useClient from "./useClient"; | ||
|
||
/** | ||
* Hook for loading tags. | ||
*/ | ||
export function useTags() { | ||
const [loading, setLoading] = React.useState(true); | ||
const [tags, setTags] = React.useState<string[]>([]); | ||
const [error, setError] = React.useState(null); | ||
const client = useClient(); | ||
|
||
React.useEffect(() => { | ||
let isEffectMounted = true; | ||
setLoading(true); | ||
|
||
async function load() { | ||
try { | ||
const tags = await client.tags.all(); | ||
if (!isEffectMounted) return; | ||
|
||
setTags(tags); | ||
setLoading(false); | ||
} catch (err: any) { | ||
if (!isEffectMounted) return; | ||
|
||
setError(err); | ||
setLoading(false); | ||
} | ||
} | ||
|
||
load(); | ||
return () => { | ||
isEffectMounted = false; | ||
}; | ||
}, []); | ||
|
||
return { loading, tags, error }; | ||
} |
This file contains 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
2 changes: 1 addition & 1 deletion
2
src/markdown/remark-slate-transformer/plugins/remark-to-slate.ts
This file contains 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 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 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 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 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,18 @@ | ||
import { Database } from "better-sqlite3"; | ||
import { Knex } from "knex"; | ||
|
||
export type ITagsClient = TagsClient; | ||
|
||
export class TagsClient { | ||
constructor( | ||
private db: Database, | ||
private knex: Knex, | ||
) {} | ||
|
||
all = async (): Promise<string[]> => { | ||
return this.db | ||
.prepare(`SELECT DISTINCT tag FROM document_tags`) | ||
.all() | ||
.map((row) => row.tag); | ||
}; | ||
} |
Oops, something went wrong.