Exemple #1
0
        public IActionResult Render(string path)
        {
            string fullPath = Path.Combine(notebook.NoteDir, path);

            NoteModel model = new NoteModel
            {
                Title    = path,
                FullPath = fullPath,
                Recent   = notebook.GetRecent(8)
            };

            // TODO - do a better job hunting for files
            if (!System.IO.File.Exists(fullPath))
            {
                return(NotFound());
            }

            string fileContent = System.IO.File.ReadAllText(fullPath);

            if (path.EndsWith(".md"))
            {
                model.NoteHtml = Markdown.ToHtml(fileContent);
            }
            else
            {
                model.NoteText = fileContent;
            }

            return(View(model));
        }