Coder Social home page Coder Social logo

Comments (5)

olayway avatar olayway commented on May 13, 2024

@rufuspollock I've advised @mohamedsalem401 to sketch out architecture design before implementing

from markdowndb.

mohamedsalem401 avatar mohamedsalem401 commented on May 13, 2024

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 avatar rufuspollock commented on May 13, 2024

@rufuspollock i've posted a design approach in the description. let me know what you think.

from markdowndb.

rufuspollock avatar rufuspollock commented on May 13, 2024

@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.

rufuspollock avatar rufuspollock commented on May 13, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.