首页 > web前端 > js教程 > 正文

Apple Notes 是我的 CMS

王林
发布: 2024-08-13 09:40:06
转载
909人浏览过

介绍

您可能已经了解过这个表情包以及 apple notes 的优越性。
Apple Notes 是我的 CMS
那么,如果您可以将其用作 cms 来管理博客内容呢?这就是我想在我的“今天我学到了”网站上尝试的。这是最终结果 https://til.julienc.me

apple notes 是我的 cms

查询苹果笔记

我们需要一种从 apple notes 中获取笔记的方法。为此,我们将使用 anyquery,它是一个 sql 数据库,可以查询几乎任何内容,包括 apple notes。

  1. 在 https://anyquery.dev/docs/#installation 安装 anyquery
  2. 安装apple notes插件:anyquery install notes
  3. 使用 sql 查询我们的笔记并将其保存为 json(在我的例子中,我的笔记位于文件夹 til 中)

    anyquery -q "select name, html_body, modification_date 
    from notes_items where folder = 'til';" --json > notes.json 
    
    登录后复制

您现在有一个文件notes.json,其中包含对象数组中的所有笔记。每个对象都有三个属性:

  • 笔记名称(name)
  • 最后修改时间(modification_date)
  • html 中的正文注释 (html_body)

例如:

[
    {
        "name": "example",
        "modification_date": "2024-08-11t00:00:00z",
        "html_body": "<h1>example</h1><p>this is an example</p>"
    }
]
登录后复制

我们的最后一个任务是将网站连接到它

连接网站

就我个人而言,我使用 astro.js。我们的第一个任务是为每个条目生成静态路径。
为此,我可以从“../../notes.json”导入注释;并将其传递给导出函数 getstaticpaths()。我还使用 slugify 函数来确保生成的 url 有效。

// [...blog].astro
import notes from "../../notes.json";

function slugify(string: string) {
    return string
        .tolowercase()
        .replace(/\s+/g, "-")
        .replace(/[^a-z0-9-]/g, "");
}

export function getstaticpaths() {
    return notes.map((note) => {
        return {
            params: {
                blog: slugify(note.name),
            },
        };
    });
}

const { blog } = astro.params;
const note = notes.find((note) => slugify(note.name) === blog);
登录后复制

生成路径后,我们需要编写一些 css 来匹配 apple notes 样式:

article.notes {
            color: #454545;
            font-size: 0.9rem;
            font-style: normal;
            font-weight: 400;
            line-height: normal;
            letter-spacing: -0.015rem;
        }

article.notes > div:first-child > h1 {
        color: #de9807;
        margin-bottom: 0.5rem;
}

... truncated (retrieve the full CSS in the repository at src/styles.css)

登录后复制

我们现在完成了!

结论

恭喜,您现在正在使用 apple notes 作为 cms。它是一款功能强大的协作式 cms,仅受您的 icloud 存储限制限制。您可以添加图像、表格、格式化文本、代码等
以下是格式选项的示例:
https://til.julienc.me/example-of-capability
Apple Notes 是我的 CMS

您可以通过执行以下操作将您自己的博客从 apple notes 部署到 vercel:

  • 克隆存储库 git clone https://github.com/julien040/apple-notes-cms
  • 运行 npm install 或 pnpm install
  • 运行 chmod u+x deploy.sh
  • 运行 vercel 来初始化并连接项目
  • 运行 ./deploy.sh 构建项目并将其推送到 vercel

链接

源代码:https://github.com/julien040/apple-notes-cms
结果:https://til.julienc.me/

以上就是Apple Notes 是我的 CMS的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:dev.to网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号