When a file such as src/www/foo/bar.m5
is processed, it is expanded with a predefined macro
VNAME
with the value
`foo/bar'. The macro matrix
uses this to work out that files
such as pub/www/foo/bar.html are to be
created. It also temporarily defines VFILE
as VNAME
plus
the suffix of the type it is generating.
VFILE
is used to create
relative links between pages within the same site. The
macro reluri
in
m5web/paths takes two parameters,
name and suffix, and
relativizes `$$name'$$suffix
against VFILE
. For example:
import(`m5web/paths')\
define(`VFILE', `foo/bar.html')\
reluri(`foo/fong', ``.html'')
reluri(`pics/pretty', ``.png'')
reluri(`home', ``.xhtml'')
reluri(`foo/bar', ``.html'')
reluri(`foo/bar', ``.xhtml'')
…yields the following:
fong.html
../pics/pretty.png
../home.xhtml
bar.html
bar.xhtml
The value of INDEXBASE
specifies which links should map to a directory-like
URI. By default, it is index, so links to
index and foo/index,
etc, will actually be encoded as
./ and foo/. For example:
import(`m5web/paths')\
define(`INDEXBASE', `home')\
define(`VFILE', `foo/bar.html')\
reluri(`foo/fong', ``.html'')
reluri(`pics/pretty', ``.png'')
reluri(`home', ``.xhtml'')
reluri(`foo/home', ``.xhtml'')
reluri(`foo/bar', ``.html'')
reluri(`foo/bar', ``.xhtml'')
…yields the following:
fong.html
../pics/pretty.png
../
./
bar.html
bar.xhtml
You should set INDEXBASE
to
nothing when generating a local page hierarchy, so that
no link to a path ending in index gets
converted to a link that doesn't work on a local
filesystem.
In m5web/hypertext, the first parameter
of macro llink
is a path
$$vname
(comparable with
VNAME
), followed by
content, and wraps $$content
in an <a>
linking to the specified
path, appending $$suffix
.
However, if this path is the same as the page you're
linking from, it will wrap the content in a
<span>
instead. The
optional parameter class is used to set
the class of the <a>
or <span>
, while
liveclass only sets the class of
<a>
, and
deadclass only sets the class of
<span>
. To reference
a fragment, provide the fragment identifier as
anchor. For example, in
src/www/baz/qux.m5:
llink(`foo/bar', `suffix'=``.html'', `anchor'=`top', ``Top of page'')
…yields the following:
<a href="../foo/bar.html#top">Top of page</a>
You're more likely to use llink_html
, which is identical, except that
suffix has a default value of HTML_LNK_SUFFIX
, which itself has a default
value of `.html'
.
To set an anchor point in a page, set id
on an appropriate element:
div(`id'=`here', ``The content'')
This sets the id
attribute on the <div>
, and it influences
llink
, such that links to this
element from within it will be dead.