Comments (5)
@rufuspollock I've advised @mohamedsalem401 to sketch out architecture design before implementing
from markdowndb.
What do we want by implementing custom fields?
We aim to provide users with a simple way to automate field generation based on a file's data.
Examples:
- Generate keywords based on the content of the file.
- Label blog posts based on the folder structure.
- Count the number of words in the content.
- Estimate the reading time based on the content.
- Detect the language of the content.
How can we do this?
We can achieve this by allowing users to define custom fields using JavaScript functions. Each function takes the following information as parameters:
- File path
- File metadata (e.g.,
tags
,title
, ...) - File body content
- File type (e.g.,
blog
, ...)
The custom field generated by the function can then be added to the document scheme.
Example Implementation:
// User-defined function to generate keywords based on content
function generateKeywords(filePath, metadata, content, fileType) {
const keywords = ....
return { keywords };
}
// Document scheme with custom field added
const documentScheme = {
keywords: { value: generateKeywords}, // this will be excuted
};
In this example, the generateKeywords
function is a placeholder for the user-defined function. Users can implement similar functions to automate the generation of custom fields based on their specific requirements. The custom field is then added to the document scheme for validation and type decleration.
from markdowndb.
@rufuspollock i've posted a design approach in the description. let me know what you think.
from markdowndb.
@mohamedsalem401 i think we probably want to operate on the ast ... (things are already parsed ...). at least in first pass i would try that ...
from markdowndb.
@mohamedsalem401 can you draft your spec as a PR to README.md (for a new section called "Computed Fields"
I think the function is something like:
function computeSomething(fileObject, ast) { // either returns null and changes in place OR returns a duplicate of the object with the altered fields ...
// my guess is to KISS and just alter in place for now ...
}
from markdowndb.
Related Issues (20)
- Link to GitHub issue incorrectly parsed as a tag HOT 2
- mddb sometimes chokes on accented characters within tags HOT 1
- Wrong table name when trying to insert tags data HOT 3
- Escaped hashes incorrectly parsed as a tag HOT 2
- Hashtag in inline code incorrectly parsed as a tag HOT 1
- Hashtag in link name incorrectly parsed as a tag HOT 2
- SQLITE_ERROR: table `tags` already exists
- Related efforts
- New feature: Implement --help option for command line HOT 2
- New feature: Glob support as alternative to directory path
- Feature addition: processing multiple directories together
- Feature request: parser for tags that are not standards. HOT 2
- Link improvements
- Strict Mode, Cross-Platform Compatibility, and JSDoc Documentation HOT 1
- Improvements to task extraction HOT 8
- extract headings to db HOT 6
- Create a documentation page for features
- Please add "db", "sql" and "database" to about. HOT 3
- Make tests for folders with 500+ files HOT 1
- Commented line within code block incorrectly parsed as tag HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdowndb.