《 窗边的小豆豆 》

bookcover|200

字段 值
作者 '(日)黑柳彻子'
ISBN 9787544288590
出版年 2018-5
出版社 南海出版公司
来源 窗边的小豆豆
评分 9.3
页码 280
分类 =this.file.etags
我的评级 =this.file.link.我的评级
书籍链接(外部) 窗边的小豆豆
书籍链接(内部) 窗边的小豆豆

内容简介:

点击展开/收起 《窗边的小豆豆》是一部影响20世纪的儿童文学杰作,讲述了作者黑柳彻子上小学时一段真实的故事。小豆豆因淘气被原学校退学后,来到巴学园。在小林校长的爱护和引导下,一般人眼里“怪怪”的小豆豆逐渐成了一个大家都能接受的孩子,并奠定了她一生的基础。 世界上最可怕的事情,莫过于有眼睛却发现不了美,有耳朵却不会欣赏音乐,有心灵却无法理解什么是真。不会感动,也不会充满激情。《窗边的小豆豆》不仅带给千万读者无数的笑声和感动,而且为现代教育的发展注入了新的活力,成为全世界极有影响的作品之一。 《窗边的小豆豆》被孙云晓、曹文轩、梅子涵、伍美珍、张弘等教育专家联袂推荐,入选九年制义务教育小学语文课本。中文简体版已突破1100万册,连续10年名列开卷全国畅销书排行榜。新版现在已经隆重上市,内文四色彩印,更温柔纯真,美观大方,适合亲子共读。
// 指定要搜索的文件夹
const targetFolder = "阅读/作家";
// 可修改的摘要长度(字符数)
const excerptLength = 300;

// 从模板变量接收作者名(可能带引号)
let rawAuthor = `【日】黑柳彻子`;
let author = rawAuthor.replace(/^['"]+|['"]+$/g, "").trim();

// 获取该目录下所有页面并过滤
let pagesInFolder = dv.pages(`"${targetFolder}"`);
let matching = pagesInFolder.filter(p => p.file.name === author || p.file.name.includes(author));

if (matching.length > 0) {
  (async () => {
    let note = matching[0];
    let path = note.file.path;
    let name = note.file.name;

    // 输出文件链接
    dv.paragraph(`**作者简介:** ${name}`);

    // 读取全文
    let file = app.vault.getAbstractFileByPath(path);
    let content = await app.vault.read(file);

    // 去除笔记属性
    content = content.replace(/^---\r?\n[\s\S]*?\r?\n---/, "").trim();

    // 提取“作家简介”标题后的首个段落,允许标题后空行
    const sectionRegex = /^###\s*作家简介[^\n]*\r?\n(?:\r?\n)?([\s\S]*?)(?=\r?\n\s*\r?\n|$)/m;
    let excerpt = '';
    const secMatch = content.match(sectionRegex);
    if (secMatch) {
      let body = secMatch[1].trim();
      excerpt = body.length > excerptLength ? body.substring(0, excerptLength) + '...' : body;
    } else {
      // 未找到标题时默认使用首个段落
      const paraMatch = content.match(/^([\s\S]*?)(?=\r?\n\s*\r?\n|$)/);
      let firstPara = paraMatch ? paraMatch[1].trim() : content.substring(0, excerptLength).trim();
      excerpt = firstPara.length > excerptLength ? firstPara.substring(0, excerptLength) + '...' : firstPara;
    }

    // 使用 <details> 实现可折叠展示摘要
    dv.paragraph(
      `<details>
<summary>点击展开/收起</summary>

${excerpt}

</details>`
    );
  })();
} else {
  dv.paragraph(`尚未添加 “${author}” 的简介。`);
}


📋 我的笔记

📜读书笔记

// dataviewjs: 根据读书笔记中是否存在“摘抄”部分的标题,选择不同渲染方式。若有摘抄部分,则只显示摘抄部分,否则显示页面封面内容。
(async () => {
  // 1. 获取书籍笔记库路径和书名变量
  const configPage = dv.pages(`#path`)
    .filter(p => String(p.file.path).includes("BookLibPath"))[0];
  if (!configPage) {
    dv.paragraph("⚠️ 未配置 `BookLibPath` 路径。");
    return;
  }
  const BookNotePath = configPage.BookNotePath;
  const rawBook = `窗边的小豆豆`;
  const bookName = rawBook.replace(/^['"]+|['"]+$/g, "").trim();

  // 2. 查找匹配笔记
  const matching = dv.pages(`"${BookNotePath}"`)
    .filter(p => p.file.name.includes(bookName));

  if (matching.length === 0) {
    // 4a. 如果没有笔记
    dv.paragraph(`尚未创建《${bookName}》的读书笔记。`);
    return;
  }

  // 3. 选第一个匹配的笔记
  const note = matching[0];
  const path = note.file.path;
  const name = note.file.name;

  // 4. 读取文件、去除 frontmatter
  const file = app.vault.getAbstractFileByPath(path);
  let content = await app.vault.read(file);
  content = content.replace(/^---\r?\n[\s\S]*?\r?\n---/, "").trim();

  // 5. 提取 “摘抄” 节
  const lines = content.split('\n');
  let capture = false;
  const sect = [];
  for (const line of lines) {
    if (/^#{1,6}\s*摘抄\s*$/.test(line)) {
      capture = true;
      continue;
    }
    if (capture && /^#{1,6}\s*\S+/.test(line)) break;
    if (capture) sect.push(line);
  }
  const excerpt = sect.join('\n').trim();

  if (excerpt) {
    // 6a. 有“摘抄”,渲染带折叠和样式的区域
    dv.paragraph(`
<div style="
  border:1px solid;
  padding:8px;
  border-radius:4px;
  margin:8px 0;
">
  <div>
    <strong>📖 书籍笔记:</strong>
  </div>
  <hr style="
    border:none;
    border-top:1px dotted;
    margin:8px 0;
  ">
  <details>
    <summary style="cursor:pointer;">📋 摘抄(点击展开/收起)</summary>
    ${excerpt}
  </details>
</div>
    `);
  } else {
    // 6b. 无“摘抄”,退回到第一段逻辑:展示封面图
    dv.paragraph("读书笔记:");
    const imagePath = path.replace(/\s+/g, '%20');
    dv.paragraph(`![](${imagePath})`);
  }
})();

🔗 微信读书

let WereadPath = dv.pages(`#path`).filter(p=>String(p.file.path).includes("BookLibPath"))[0].WereadPath;
let link = dv.pages(`"${WereadPath}"`)
.filter(p=>String(p.file.name).includes("窗边的小豆豆")).file.path;
if(link[0])
{
	let path = link[0].replace(/\s+/g, '%20');
	dv.paragraph("![]("+path+"#高亮划线)");
}

let WereadPath = dv.pages(`#path`).filter(p=>String(p.file.path).includes("BookLibPath"))[0].WereadPath;
let link = dv.pages(`"${WereadPath}"`)
.filter(p=>String(p.file.name).includes("窗边的小豆豆")).file.path;
if(link[0])
{
	let path = link[0].replace(/\s+/g, '%20');
	dv.paragraph("![]("+path+"#读书笔记)");
}


let WereadPath = dv.pages(`#path`).filter(p=>String(p.file.path).includes("BookLibPath"))[0].WereadPath;
let link = dv.pages(`"${WereadPath}"`)
.filter(p=>String(p.file.name).includes("窗边的小豆豆")).file.path;
if(link[0])
{
	let path = link[0].replace(/\s+/g, '%20');
	dv.paragraph("![]("+path+"#本书评论)");
}

🔖 Zotero

let ZoteroPath = dv.pages(`#path`).filter(p=>String(p.file.path).includes("BookLibPath"))[0].ZoteroPath;
let link = dv.pages(`"${ZoteroPath}"`)
.filter(p=>String(p.file.name).includes("窗边的小豆豆")).file.path;
if(link[0])
{
	let path = link[0].replace(/\s+/g, '%20');
	dv.paragraph("![]("+path+"#Zotero链接)");
}
let ZoteroPath = dv.pages(`#path`).filter(p=>String(p.file.path).includes("BookLibPath"))[0].ZoteroPath;
let link = dv.pages(`"${ZoteroPath}"`)
.filter(p=>String(p.file.name).includes("窗边的小豆豆")).file.path;
if(link[0])
{
	let path = link[0].replace(/\s+/g, '%20');
	dv.paragraph("![]("+path+"#注释)");
}

🌐 其它相关