Content モジュールでRSS を拡張する
Published at 2005-07-11 (Mon) 18:37 in Movable Type, RSS
Movable Type のデフォルトのテンプレートは RSS の description に HTML マークアップされたテキストが挿入されるようになっている。本来、記事の概要を示すエレメントに HTML タグを含む記事全文が埋め込むのはよくないし、概要を記述できないので Content モジュールを使って記事全文と概要の両方を記述できるようにしてみました。
description 要素に日記や blog 記事の全文を記載すると、コンパクトなサマリーを期待する読者には歓迎されないかも知れないので、description 要素は短くとどめ、全文は後述する Content モジュール の content:encoded 要素 に記述すると良いでしょう。
テンプレートの修正は簡単。
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:cc="http://web.resource.org/cc/"
xmlns="http://purl.org/rss/1.0/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xml:lang="ja"
>
中略
<MTEntries lastn="15">
<item rdf:about="<$MTEntryPermalink encode_xml="1"$>">
<title><$MTEntryTitle encode_xml="1"$></title>
<link><$MTEntryPermalink encode_xml="1"$></link>
<description><$MTEntryExcerpt encode_xml="1"$></description>
<content:encoded><$MTEntryBody encode_xml="1"$></content:encoded>
<dc:subject><$MTEntryCategory encode_xml="1"$></dc:subject>
<dc:creator><$MTEntryAuthorNickname encode_xml="1"$></dc:creator>
<dc:date><$MTEntryDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></dc:date>
</item>
</MTEntries>
content:encoded でマークアップされる部分、 MT テンプレートタグでいうと <$MTEntryBody$> 内にに含まれるリンクや画像は絶対 URI で指定する必要があるのでエントリーを書くときに注意する必要があります。
