Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/2anki/get-notion-object-title
get human readable names from Notion objects
https://github.com/2anki/get-notion-object-title
Last synced: 1 day ago
JSON representation
get human readable names from Notion objects
- Host: GitHub
- URL: https://github.com/2anki/get-notion-object-title
- Owner: 2anki
- License: mit
- Created: 2023-07-13T13:39:52.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-09T09:15:19.000Z (24 days ago)
- Last Synced: 2024-09-10T19:07:44.079Z (23 days ago)
- Language: TypeScript
- Size: 403 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Get Notion Object Title
The [Notion API](https://developers.notion.com/reference/intro) does not provide a simple way to retrieve the title of an object.
This module provides you with a simple API where you can pass in a Notion Object
and receive a human readable string.## Install
> npm i get-notion-object-title
## Usage
```typescript
import getNotionObjectTitle from 'get-notion-object-title';getNotionObjectTitle(yourBlock); // returns "Human readable block title"
```### Disable emoji
If you already have a way to handle icons and would like to only get the text, you can
disable the emojis by passing in an option.```typescript
getNotionObjectTitle(yourBlock, { emoji: false }); // returns "Human readable block title"
```## How does it work?
The `getNotionObjectTitle` takes a Notion object as input and returns a string.
Depending on the type of the object there are some rules that are applied.### Page
If the [page](https://developers.notion.com/reference/page) has any of the following properties they will be used and they do exclude each other:
- Title
- Page
- Name### Database
The [database](https://developers.notion.com/reference/database) uses the top level `title` attribute.
### Other
The remaining blocks are converted to plain text using the [rich text items](https://developers.notion.com/reference/rich-text).
## License
Unless otherwise specified in the source:
The code is licensed under the [MIT](./LICENSE) Copyright (c) 2023, Alexander Alemayhu.