{"id":19462492,"url":"https://github.com/shushuicu/typecho-theme-development-framework","last_synced_at":"2025-04-25T08:31:10.381Z","repository":{"id":262010624,"uuid":"885552112","full_name":"ShuShuicu/Typecho-Theme-Development-Framework","owner":"ShuShuicu","description":"TTDF是一个Typecho主题模板开发框架；面向小白，免费、简单、开源，提供了一些常用的功能以及调用函数，支持REST API。","archived":false,"fork":false,"pushed_at":"2025-04-19T16:14:20.000Z","size":427,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T19:27:32.387Z","etag":null,"topics":["php","typecho","typecho-theme"],"latest_commit_sha":null,"homepage":"https://blog.miomoe.cn/search?key=Typecho","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShuShuicu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-08T20:12:40.000Z","updated_at":"2025-04-19T16:14:23.000Z","dependencies_parsed_at":"2024-11-09T22:25:04.505Z","dependency_job_id":"39d96d03-857c-40dc-94cb-34beed7148c7","html_url":"https://github.com/ShuShuicu/Typecho-Theme-Development-Framework","commit_stats":null,"previous_names":["shushuicu/typecho-theme-development-framework"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShuShuicu%2FTypecho-Theme-Development-Framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShuShuicu%2FTypecho-Theme-Development-Framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShuShuicu%2FTypecho-Theme-Development-Framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShuShuicu%2FTypecho-Theme-Development-Framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShuShuicu","download_url":"https://codeload.github.com/ShuShuicu/Typecho-Theme-Development-Framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250782028,"owners_count":21486373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","typecho","typecho-theme"],"created_at":"2024-11-10T18:01:53.719Z","updated_at":"2025-04-25T08:31:10.375Z","avatar_url":"https://github.com/ShuShuicu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typecho Theme Development Framework\n\n\u003e 一个 Typecho 主题开发框架 v2 版，~~还算不上框架只能说让开发变得更简单些~~\n\n特别感谢[@Sualiu](https://github.com/Sualiu)\n\n[开发示例](https://www.bilibili.com/video/BV1qLQKYmE6j)\n\n### 类与方法\n\n调用方法时值为 true 直接 echo 输出，如果为 false 则返回值。  \nGet::SiteUrl(true) 为 echo 输出  \nGet::SiteUrl(false) 为 return 返回值\n\n#### TTDF 类\n\n|    方法    |        描述         |        示例         |\n| :--------: | :-----------------: | :-----------------: |\n|    Ver     |   获取框架版本号    |    TTDF::Ver();     |\n| TypechoVer | 获取 Typecho 版本号 | TTDF::TypechoVer(); |\n|  HeadMeta  |   调用 meta 标签    |  TTDF::HeadMeta();  |\n| HeadMetaOG |    调用 OG 标签     | TTDF::HeadMetaOG(); |\n\n#### Get 类\n\n获取站点信息及其他通用功能。\n\n|            方法             |       描述       |          示例           |\n| :-------------------------: | :--------------: | :---------------------: |\n|          SiteUrl()          |  获取站点的 URL  |     Get::SiteUrl();     |\n|          PageUrl()          |   获取当前url    |     Get::PageUrl();     |\n|         SiteName()          |   获取站点名称   |    Get::SiteName();     |\n|       SiteKeywords()        |  获取站点关键词  |  Get::SiteKeywords();   |\n|      SiteDescription()      |   获取站点描述   | Get::SiteDescription(); |\n|       Options($param)       |    获取配置项    |  Get::Options('name');  |\n|       Fields($param)        |     获取字段     |  Get::Fields('name');   |\n|          Is($type)          | 判断当前页面类型 |    Get::Is('type');     |\n|           Next()            |    返回数组值    |      Get::Next();       |\n|    PageNav($prev, $next)    |   获取分页导航   |     Get::PageNav();     |\n| PageLink($link, $type = '') |   获取分页链接   |    Get::PageLink();     |\n|           Total()           |   获取文章总数   |      Get::Total();      |\n|         PageSize()          |  获取每页文章数  |    Get::PageSize();     |\n|        CurrentPage()        |   获取当前页码   |   Get::CurrentPage();   |\n|         Permalink()         |   获取文章链接   |    Get::Permalink();    |\n|        Field($field)        |  获取自定义字段  |      Get::Field();      |\n\n\u003e Get::PageUrl() 方法可自定义输出，示例如下：\n\u003e 默认调用  \n\u003e Get::PageUrl();  \n\u003e 移除所有查询参数  \n\u003e Get::PageUrl(true, false, null, true);  \n\u003e 屏蔽指定参数  \n\u003e Get::PageUrl(true, false, ['foo', 'baz']);  \n\u003e 移除所有查询参数并移除端口  \n\u003e Get::PageUrl(true, true, null, true);  \n\n#### GetTheme 类\n\n获取主题的相关信息。\n\n| 方法     | 描述           | 示例                |\n| -------- | -------------- | ------------------- |\n| Url()    | 获取主题的 URL | GetTheme::Url();    |\n| Name()   | 获取主题名称   | GetTheme::Name();   |\n| Author() | 获取主题作者   | GetTheme::Author(); |\n| Ver()    | 获取主题版本号 | GetTheme::Ver();    |\n\n#### GetPost 类\n\n获取文章的相关信息。\n\n|       方法        |       描述       |            示例             |\n| :---------------: | :--------------: | :-------------------------: |\n|      List()       |   获取文章列表   |      GetPost::List();       |  |\n|      Title()      |   获取文章标题   |      GetPost::Title();      |\n|      Date()       |   获取文章日期   |      GetPost::Date();       |\n|    Category()     |   获取文章分类   |    GetPost::Category();     |\n|      Tags()       |   获取文章标签   |      GetPost::Tags();       |\n|     Excerpt()     |   获取文章摘要   |     GetPost::Excerpt();     |\n|    Permalink()    |   获取文章链接   |    GetPost::Permalink();    |\n|     Content()     |   获取文章内容   |     GetPost::Content();     |\n|   DB_Content()    |  获取文章md内容  |   GetPost::DB_Content();    |\n| DB_Content_Html() | 获取文章html内容 | GetPost::DB_Content_Html(); |\n|    WordCount()    |   获取文章字数   |    GetPost::WordCount();    |\n|    PostsNum()     |    获取文章数    |    GetPost::PostsNum();     |\n|   CurrentPage()   |   获取当前页码   |   GetPost::CurrentPage();   |\n|  ArchiveTitle()   | 获取当前页面标题 |  GetPost::ArchiveTitle();   |\n|     Author()      |   获取文章作者   |     GetPost::Author();\u003e     |\n| AuthorPermalink() |   获取作者链接   | GetPost::AuthorPermalink(); |\n\n\u003e GetPost:List() 方法可自定义输出，示例如下：\n\u003e 默认调用\n``` php\n while (GetPost::List()) {\n    \n};\n```\n\u003e 自定义调用\n``` php\n\u003c?php \n// 第一个文章列表\n$featuredPosts = GetPost::List (\n    [\n        'pageSize' =\u003e 3, \n        'type' =\u003e 'category', \n        'mid' =\u003e 1\n    ]\n); \n?\u003e\n\u003c?php while ($featuredPosts-\u003enext()) { ?\u003e\n    \u003cdiv class=\"featured-post\"\u003e\n        \u003ch2\u003e\u003c?php GetPost::Title() ?\u003e\u003c/h2\u003e\n        \u003cp\u003e\u003c?php GetPost::Excerpt(100) ?\u003e\u003c/p\u003e\n        \u003c?php GetPost::Date('Y年m月d日') ?\u003e\n    \u003c/div\u003e\n\u003c?php }; ?\u003e\n\u003c?php GetPost::unbindArchive(); // 结束当前绑定 ?\u003e\n```\n\n#### GetAuthor 类\n\n获取作者的相关信息。\n\n|    方法     |       描述       |          示例           |\n| :---------: | :--------------: | :---------------------: |\n|   Name()    | 获取当前页面标题 |   GetAuthor::Name();    |\n|  Author()   |   获取文章作者   |  GetAuthor::Author();\u003e  |\n| Permalink() |   获取作者链接   | GetAuthor::Permalink(); |\n\n#### GetComments 类\n\n获取评论的相关信息。\n\n|      方法      |     描述      |             示例             |\n| :------------: | :-----------: | :--------------------------: |\n|   Comments()   |   获取评论    |   GetComments::Comments();   |\n| CommentsPage() | 获取评论页面  | GetComments::CommentsPage(); |\n| CommentsList() | 获取评论列表  | GetComments::CommentsList(); |\n| CommentsNum()  |  获取评论数   | GetComments::CommentsNum();  |\n| CommentsForm() | 获取评论表单  | GetComments::CommentsForm(); |\n|  RespondId()   |  获取评论 id  |  GetComments::RespondId();\u003e  |\n| CancelReply()  | 获取取消回复  | GetComments::CancelReply();  |\n|   Remember()   | 获取 Remember |   GetComments::Remember();   |\n|   PageNav()    | 获取评论分页  |   GetComments::PageNav();    |\n\n#### GetFunctions 类\n\n提供一些常用的功能函数。\n\n|    方法     |     描述     |            示例            |\n| :---------: | :----------: | :------------------------: |\n| TimerStop() | 获取加载时间 | GetFunctions::TimerStop(); |\n\n### REST API\n\n一个简单的 REST API，你可以使用它来获取一些数据。\n\n| 调用  |             路由             |      参数      |     描述     |\n| :---: | :--------------------------: | :------------: | :----------: |\n|  Get  |  ?action=api\u0026path=PostList   | pageSize, page | 获取文章列表 |\n|  Get  |  ?action=api\u0026path=Category   |      cid       | 获取分类列表 |\n|  Get  |     ?action=api\u0026path=Tag     |      tid       | 获取标签列表 |\n|  Get  | ?action=api\u0026path=PostContent |      cid       | 获取文章数据 |\n\n### 钩子\n\u003e TTDF默认有两个钩子可以挂，分别为`load_head`\u0026`load_foot`\n\n#### 使用方法\n\n在页面 如index.php写\n```php\n\u003c?php \nTTDF_Hook::add_action('load_foot', function () {\n?\u003e\n\u003cscript type=\"text/javascript\"\u003econsole.log('TTDF NB')\u003c/script\u003e\n\u003c?php\n});\n```\n\nf12打开控制台就会看到打印的`TTDF NB`，挂钩的内容仅在当前页面生效。\n也就是说写到`index.php`只有首页才会输出`TTDF NB`，其他页面则没有。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshushuicu%2Ftypecho-theme-development-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshushuicu%2Ftypecho-theme-development-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshushuicu%2Ftypecho-theme-development-framework/lists"}